@@ -126,6 +126,36 @@ func TestAccGithubEMUGroupMapping(t *testing.T) {
126126 },
127127 })
128128 })
129+
130+ t .Run ("forces new when switching to different team" , func (t * testing.T ) {
131+ t .Skip ("Skipping this test because we don't have terraform-plugin-testing available yet." )
132+ randomID := acctest .RandString (5 )
133+ teamName1 := fmt .Sprintf ("%semu1-%s" , testResourcePrefix , randomID )
134+ teamName2 := fmt .Sprintf ("%semu2-%s" , testResourcePrefix , randomID )
135+
136+ resource .Test (t , resource.TestCase {
137+ PreCheck : func () { skipUnlessEnterprise (t ) },
138+ ProviderFactories : providerFactories ,
139+ CheckDestroy : testAccCheckGithubEMUGroupMappingDestroy ,
140+ Steps : []resource.TestStep {
141+ {
142+ Config : testAccGithubEMUGroupMappingTwoTeamsConfig (teamName1 , teamName2 , groupID , "test1" ),
143+ Check : resource .ComposeTestCheckFunc (
144+ resource .TestCheckResourceAttr ("github_emu_group_mapping.test" , "team_slug" , teamName1 ),
145+ ),
146+ },
147+ {
148+ Config : testAccGithubEMUGroupMappingTwoTeamsConfig (teamName1 , teamName2 , groupID , "test2" ),
149+ // ConfigPlanChecks: resource.ConfigPlanChecks{
150+ // PreApply: []plancheck.PlanCheck{
151+ // plancheckExpectKnownValues("github_emu_group_mapping.test", "team_slug", teamName2),
152+ // plancheck.ExpectResourceAction("github_emu_group_mapping.test", plancheck.ResourceActionDestroyBeforeCreate), // Verify that ForceNew is triggered
153+ // },
154+ // },
155+ },
156+ },
157+ })
158+ })
129159}
130160
131161func testAccCheckGithubEMUGroupMappingDestroy (s * terraform.State ) error {
@@ -183,3 +213,20 @@ func testAccGithubEMUGroupMappingConfig(teamName string, groupID int) string {
183213 }
184214 ` , teamName , groupID )
185215}
216+
217+ func testAccGithubEMUGroupMappingTwoTeamsConfig (teamName1 , teamName2 string , groupID int , useTeam string ) string {
218+ return fmt .Sprintf (`
219+ resource "github_team" "test1" {
220+ name = "%s"
221+ description = "EMU group mapping test team 1"
222+ }
223+ resource "github_team" "test2" {
224+ name = "%s"
225+ description = "EMU group mapping test team 2"
226+ }
227+ resource "github_emu_group_mapping" "test" {
228+ team_slug = github_team.%s.slug
229+ group_id = %d
230+ }
231+ ` , teamName1 , teamName2 , useTeam , groupID )
232+ }
0 commit comments