Skip to content

Commit

Permalink
tests: Add test for user role with permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-cleary committed Apr 1, 2021
1 parent e255a57 commit a7980fa
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions octopusdeploy/resource_user_role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,36 @@ func TestAccUserRoleBasic(t *testing.T) {
})
}

func TestAccUserRolePermissions(t *testing.T) {
localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha)
name := acctest.RandStringFromCharSet(16, acctest.CharSetAlpha)

resource.Test(t, resource.TestCase{
CheckDestroy: testAccUserRoleCheckDestroy,
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testUserRolePermissions(localName, name),
},
},
})
}

func testUserRoleMinimum(localName string, name string) string {
return fmt.Sprintf(`resource "octopusdeploy_user_role" "%s" {
name = "%s"
}`, localName, name)
}

func testUserRolePermissions(localName string, name string) string {
return fmt.Sprintf(`resource "octopusdeploy_user_role" "%s" {
name = "%s"
granted_space_permissions = ["AccountCreate"]
granted_system_permissions = ["SpaceView"]
}`, localName, name)
}

func testAccUserRoleCheckDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*octopusdeploy.Client)
for _, rs := range s.RootModule().Resources {
Expand Down

0 comments on commit a7980fa

Please sign in to comment.