Skip to content

Commit

Permalink
changes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jcieslak committed Feb 28, 2024
1 parent 3064561 commit 718c670
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 10 deletions.
12 changes: 2 additions & 10 deletions pkg/resources/grant_privileges_to_account_role_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -934,9 +934,8 @@ func TestAcc_GrantPrivilegesToAccountRole_MultiplePartsInRoleName(t *testing.T)
nameBytes[3] = '.'
nameBytes[6] = '.'
name := string(nameBytes)
roleName := sdk.NewAccountObjectIdentifier(name).FullyQualifiedName()
configVariables := config.Variables{
"name": config.StringVariable(roleName),
"name": config.StringVariable(name),
"privileges": config.ListVariable(
config.StringVariable(string(sdk.GlobalPrivilegeCreateDatabase)),
config.StringVariable(string(sdk.GlobalPrivilegeCreateRole)),
Expand All @@ -958,16 +957,9 @@ func TestAcc_GrantPrivilegesToAccountRole_MultiplePartsInRoleName(t *testing.T)
ConfigDirectory: acc.ConfigurationDirectory("TestAcc_GrantPrivilegesToAccountRole/OnAccount"),
ConfigVariables: configVariables,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "account_role_name", roleName),
resource.TestCheckResourceAttr(resourceName, "account_role_name", name),
),
},
{
ConfigDirectory: acc.ConfigurationDirectory("TestAcc_GrantPrivilegesToAccountRole/OnAccount"),
ConfigVariables: configVariables,
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Expand Down
35 changes: 35 additions & 0 deletions pkg/resources/grant_privileges_to_role_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1090,3 +1090,38 @@ func TestAcc_GrantPrivilegesToRole_ImportedPrivileges(t *testing.T) {
},
})
}

func TestAcc_GrantPrivilegesToRole_MultiplePartsInRoleName(t *testing.T) {
nameBytes := []byte(strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)))
nameBytes[3] = '.'
nameBytes[6] = '.'
name := string(nameBytes)
configVariables := config.Variables{
"name": config.StringVariable(name),
"privileges": config.ListVariable(
config.StringVariable(string(sdk.GlobalPrivilegeCreateDatabase)),
config.StringVariable(string(sdk.GlobalPrivilegeCreateRole)),
),
"with_grant_option": config.BoolVariable(true),
}
resourceName := "snowflake_grant_privileges_to_role.test"

resource.Test(t, resource.TestCase{
ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories,
PreCheck: func() { acc.TestAccPreCheck(t) },
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.RequireAbove(tfversion.Version1_5_0),
},
CheckDestroy: testAccCheckAccountRolePrivilegesRevoked(name),
Steps: []resource.TestStep{
{
PreConfig: func() { createAccountRoleOutsideTerraform(t, name) },
ConfigDirectory: acc.ConfigurationDirectory("TestAcc_GrantPrivilegesToRole/OnAccount"),
ConfigVariables: configVariables,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "role_name", name),
),
},
},
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resource "snowflake_grant_privileges_to_role" "test" {
role_name = var.name
privileges = var.privileges
on_account = true
with_grant_option = var.with_grant_option
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
variable "name" {
type = string
}

variable "privileges" {
type = list(string)
}

variable "with_grant_option" {
type = bool
}

0 comments on commit 718c670

Please sign in to comment.