@@ -300,6 +300,30 @@ func TestAccTFERegistryModule_publicRegistryModule(t *testing.T) {
300300 })
301301}
302302
303+ func TestAccTFERegistryModule_vcsRepoWithTagField (t * testing.T ) {
304+ skipUnlessBeta (t )
305+ rInt := rand .New (rand .NewSource (time .Now ().UnixNano ())).Int ()
306+
307+ resource .Test (t , resource.TestCase {
308+ PreCheck : func () {
309+ testAccPreCheck (t )
310+ testAccPreCheckTFERegistryModule (t )
311+ },
312+ Providers : testAccProviders ,
313+ Steps : []resource.TestStep {
314+ {
315+ Config : testAccTFERegistryModule_vcsRepoWithFalseTagField (rInt ),
316+ Check : resource .ComposeTestCheckFunc (
317+ resource .TestCheckResourceAttr ("tfe_registry_module.foobar" , "publishing_mechanism" , "branch" ),
318+ resource .TestCheckResourceAttr ("tfe_registry_module.foobar" , "test_config.0.tests_enabled" , strconv .FormatBool (false )),
319+ resource .TestCheckResourceAttr ("tfe_registry_module.foobar" , "vcs_repo.0.tags" , strconv .FormatBool (false )),
320+ resource .TestCheckResourceAttr ("tfe_registry_module.foobar" , "vcs_repo.0.branch" , "main" ),
321+ ),
322+ },
323+ },
324+ })
325+ }
326+
303327func TestAccTFERegistryModule_noCodeModule (t * testing.T ) {
304328 skipIfEnterprise (t )
305329
@@ -633,6 +657,25 @@ func TestAccTFERegistryModule_branchAndTagsEnabledOnCreate(t *testing.T) {
633657 })
634658}
635659
660+ func TestAccTFERegistryModule_branchAndTagsDisabledOnCreate (t * testing.T ) {
661+ skipUnlessBeta (t )
662+ rInt := rand .New (rand .NewSource (time .Now ().UnixNano ())).Int ()
663+
664+ resource .Test (t , resource.TestCase {
665+ PreCheck : func () {
666+ testAccPreCheck (t )
667+ testAccPreCheckTFERegistryModule (t )
668+ },
669+ Providers : testAccProviders ,
670+ Steps : []resource.TestStep {
671+ {
672+ Config : testAccTFERegistryModule_vcsWithBranchAndTagsDisabled (rInt ),
673+ ExpectError : regexp .MustCompile (`tags must be set to true when no branch is provided` ),
674+ },
675+ },
676+ })
677+ }
678+
636679func TestAccTFERegistryModule_branchAndTagsEnabledOnUpdate (t * testing.T ) {
637680 rInt := rand .New (rand .NewSource (time .Now ().UnixNano ())).Int ()
638681
@@ -660,6 +703,34 @@ func TestAccTFERegistryModule_branchAndTagsEnabledOnUpdate(t *testing.T) {
660703 })
661704}
662705
706+ func TestAccTFERegistryModule_branchAndTagsDisabledOnUpdate (t * testing.T ) {
707+ skipUnlessBeta (t )
708+ rInt := rand .New (rand .NewSource (time .Now ().UnixNano ())).Int ()
709+
710+ resource .Test (t , resource.TestCase {
711+ PreCheck : func () {
712+ testAccPreCheck (t )
713+ testAccPreCheckTFERegistryModule (t )
714+ },
715+ Providers : testAccProviders ,
716+ Steps : []resource.TestStep {
717+ {
718+ Config : testAccTFERegistryModule_vcsTags (rInt ),
719+ Check : resource .ComposeTestCheckFunc (
720+ resource .TestCheckResourceAttr ("tfe_registry_module.foobar" , "publishing_mechanism" , "git_tag" ),
721+ resource .TestCheckNoResourceAttr ("tfe_registry_module.foobar" , "test_config.0.tests_enabled" ),
722+ resource .TestCheckResourceAttr ("tfe_registry_module.foobar" , "vcs_repo.0.tags" , strconv .FormatBool (true )),
723+ resource .TestCheckResourceAttr ("tfe_registry_module.foobar" , "vcs_repo.0.branch" , "" ),
724+ ),
725+ },
726+ {
727+ Config : testAccTFERegistryModule_vcsWithBranchAndTagsDisabled (rInt ),
728+ ExpectError : regexp .MustCompile (`tags must be set to true when no branch is provided` ),
729+ },
730+ },
731+ })
732+ }
733+
663734func TestAccTFERegistryModuleImport_nonVCSPrivateRM (t * testing.T ) {
664735 rInt := rand .New (rand .NewSource (time .Now ().UnixNano ())).Int ()
665736
@@ -1175,6 +1246,37 @@ resource "tfe_registry_module" "foobar" {
11751246 envGithubRegistryModuleIdentifer )
11761247}
11771248
1249+ func testAccTFERegistryModule_vcsWithBranchAndTagsDisabled (rInt int ) string {
1250+ return fmt .Sprintf (`
1251+ resource "tfe_organization" "foobar" {
1252+ name = "tst-terraform-%d"
1253+ 1254+ }
1255+
1256+ resource "tfe_oauth_client" "foobar" {
1257+ organization = tfe_organization.foobar.name
1258+ api_url = "https://api.github.com"
1259+ http_url = "https://github.com"
1260+ oauth_token = "%s"
1261+ service_provider = "github"
1262+ }
1263+
1264+ resource "tfe_registry_module" "foobar" {
1265+ organization = tfe_organization.foobar.name
1266+ vcs_repo {
1267+ display_identifier = "%s"
1268+ identifier = "%s"
1269+ oauth_token_id = tfe_oauth_client.foobar.oauth_token_id
1270+ branch = ""
1271+ tags = false
1272+ }
1273+ }` ,
1274+ rInt ,
1275+ envGithubToken ,
1276+ envGithubRegistryModuleIdentifer ,
1277+ envGithubRegistryModuleIdentifer )
1278+ }
1279+
11781280func testAccTFERegistryModule_vcsTags (rInt int ) string {
11791281 return fmt .Sprintf (`
11801282resource "tfe_organization" "foobar" {
@@ -1205,6 +1307,36 @@ resource "tfe_registry_module" "foobar" {
12051307 envGithubRegistryModuleIdentifer ,
12061308 envGithubRegistryModuleIdentifer )
12071309}
1310+ func testAccTFERegistryModule_vcsRepoWithFalseTagField (rInt int ) string {
1311+ return fmt .Sprintf (`
1312+ resource "tfe_organization" "foobar" {
1313+ name = "tst-terraform-%d"
1314+ 1315+ }
1316+
1317+ resource "tfe_oauth_client" "foobar" {
1318+ organization = tfe_organization.foobar.name
1319+ api_url = "https://api.github.com"
1320+ http_url = "https://github.com"
1321+ oauth_token = "%s"
1322+ service_provider = "github"
1323+ }
1324+
1325+ resource "tfe_registry_module" "foobar" {
1326+ organization = tfe_organization.foobar.name
1327+ vcs_repo {
1328+ display_identifier = "%s"
1329+ identifier = "%s"
1330+ oauth_token_id = tfe_oauth_client.foobar.oauth_token_id
1331+ branch = "main"
1332+ tags = false
1333+ }
1334+ }` ,
1335+ rInt ,
1336+ envGithubToken ,
1337+ envGithubRegistryModuleIdentifer ,
1338+ envGithubRegistryModuleIdentifer )
1339+ }
12081340
12091341func testAccTFERegistryModule_GitHubApp (rInt int ) string {
12101342 return fmt .Sprintf (`
0 commit comments