Skip to content

Commit

Permalink
add test cases for team attrib default_role
Browse files Browse the repository at this point in the history
  • Loading branch information
imjaroiswebdev committed Oct 25, 2023
1 parent 1ac4a83 commit 741efc2
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions pagerduty/resource_pagerduty_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func resourcePagerDutyTeam() *schema.Resource {
"default_role": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
},
}
Expand Down
44 changes: 44 additions & 0 deletions pagerduty/resource_pagerduty_team_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,39 @@ func TestAccPagerDutyTeam_Basic(t *testing.T) {
})
}

func TestAccPagerDutyTeam_DefaultRole(t *testing.T) {
team := fmt.Sprintf("tf-%s", acctest.RandString(5))
defaultRole := "manager"
defaultRoleUpdated := "none"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckPagerDutyTeamDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckPagerDutyTeamDefaultRoleConfig(team, defaultRole),
Check: resource.ComposeTestCheckFunc(
testAccCheckPagerDutyTeamExists("pagerduty_team.foo"),
resource.TestCheckResourceAttr(
"pagerduty_team.foo", "name", team),
resource.TestCheckResourceAttr(
"pagerduty_team.foo", "default_role", defaultRole),
resource.TestCheckResourceAttrSet(
"pagerduty_team.foo", "html_url"),
),
},
{
Config: testAccCheckPagerDutyTeamDefaultRoleConfig(team, defaultRoleUpdated),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"pagerduty_team.foo", "default_role", defaultRoleUpdated),
),
},
},
})
}

func TestAccPagerDutyTeam_Parent(t *testing.T) {
team := fmt.Sprintf("tf-%s", acctest.RandString(5))
parent := fmt.Sprintf("tf-%s", acctest.RandString(5))
Expand Down Expand Up @@ -179,6 +212,17 @@ resource "pagerduty_team" "foo" {
}`, team)
}

func testAccCheckPagerDutyTeamDefaultRoleConfig(team, defaultRole string) string {
return fmt.Sprintf(`
resource "pagerduty_team" "foo" {
name = "%s"
description = "foo"
default_role = "%s"
}
`, team, defaultRole)
}

func testAccCheckPagerDutyTeamWithParentConfig(team, parent string) string {
return fmt.Sprintf(`
resource "pagerduty_team" "parent" {
Expand Down

0 comments on commit 741efc2

Please sign in to comment.