@@ -72,11 +72,6 @@ func TestAccGithubRepositoryEnvironmentDeploymentPolicyBranch(t *testing.T) {
7272 Config : config ,
7373 Check : check ,
7474 },
75- {
76- ResourceName : "github_repository_environment_deployment_policy.test" ,
77- ImportState : true ,
78- ImportStateVerify : true ,
79- },
8075 },
8176 })
8277 })
@@ -199,6 +194,75 @@ func TestAccGithubRepositoryEnvironmentDeploymentPolicyBranchUpdate(t *testing.T
199194 })
200195}
201196
197+ func TestAccGithubRepositoryEnvironmentDeploymentPolicyBranch_import (t * testing.T ) {
198+ randomID := acctest .RandStringFromCharSet (5 , acctest .CharSetAlphaNum )
199+ repoName := fmt .Sprintf ("%senv-deploy-%s" , testResourcePrefix , randomID )
200+
201+ config := fmt .Sprintf (`
202+
203+ data "github_user" "current" {
204+ username = ""
205+ }
206+
207+ resource "github_repository" "test" {
208+ name = "%s"
209+ ignore_vulnerability_alerts_during_read = true
210+ }
211+
212+ resource "github_repository_environment" "test" {
213+ repository = github_repository.test.name
214+ environment = "environment/test"
215+ wait_timer = 10000
216+ reviewers {
217+ users = [data.github_user.current.id]
218+ }
219+ deployment_branch_policy {
220+ protected_branches = false
221+ custom_branch_policies = true
222+ }
223+ }
224+
225+ resource "github_repository_environment_deployment_policy" "test" {
226+ repository = github_repository.test.name
227+ environment = github_repository_environment.test.environment
228+ branch_pattern = "main"
229+ }
230+
231+ ` , repoName )
232+
233+ resource .Test (t , resource.TestCase {
234+ PreCheck : func () { skipUnauthenticated (t ) },
235+ ProviderFactories : providerFactories ,
236+ Steps : []resource.TestStep {
237+ {
238+ Config : config ,
239+ Check : resource .ComposeTestCheckFunc (
240+ resource .TestCheckResourceAttr (
241+ "github_repository_environment_deployment_policy.test" , "repository" ,
242+ repoName ,
243+ ),
244+ resource .TestCheckResourceAttr (
245+ "github_repository_environment_deployment_policy.test" , "environment" ,
246+ "environment/test" ,
247+ ),
248+ resource .TestCheckResourceAttr (
249+ "github_repository_environment_deployment_policy.test" , "branch_pattern" ,
250+ "main" ,
251+ ),
252+ resource .TestCheckNoResourceAttr (
253+ "github_repository_environment_deployment_policy.test" , "tag_pattern" ,
254+ ),
255+ ),
256+ },
257+ {
258+ ResourceName : "github_repository_environment_deployment_policy.test" ,
259+ ImportState : true ,
260+ ImportStateVerify : true ,
261+ },
262+ },
263+ })
264+ }
265+
202266func TestAccGithubRepositoryEnvironmentDeploymentPolicyTag (t * testing.T ) {
203267 t .Run ("creates a repository environment with tag-based deployment policy" , func (t * testing.T ) {
204268 randomID := acctest .RandStringFromCharSet (5 , acctest .CharSetAlphaNum )
0 commit comments