Skip to content
This repository was archived by the owner on Jan 17, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions redshift/resource_redshift_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ func redshiftDatabase() *schema.Resource {
Optional: true,
Computed: true,
Description: "Owner of the database, usually the user who created it",
StateFunc: func(val interface{}) string {
return strings.ToLower(val.(string))
},
},
databaseConnLimitAttr: {
Type: schema.TypeInt,
Expand Down
3 changes: 0 additions & 3 deletions redshift/resource_redshift_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ Groups are collections of users who are all granted whatever privileges are asso
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
StateFunc: func(val interface{}) string {
return strings.ToLower(val.(string))
},
},
Description: "List of the user names to add to the group",
},
Expand Down
38 changes: 22 additions & 16 deletions redshift/resource_redshift_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)
Expand Down Expand Up @@ -39,30 +40,33 @@ func TestAccRedshiftGroup_Basic(t *testing.T) {
}

func TestAccRedshiftGroup_Update(t *testing.T) {

var configCreate = `
groupName := strings.ReplaceAll(acctest.RandomWithPrefix("TF_acc_group"), "-", "_")
groupNameUpdated := strings.ReplaceAll(acctest.RandomWithPrefix("tf_acc_group_updated"), "-", "_")
userName1 := strings.ReplaceAll(acctest.RandomWithPrefix("TF_Acc_Group_User"), "-", "_")
userName2 := strings.ReplaceAll(acctest.RandomWithPrefix("tf_acc_group_user"), "-", "_")
configCreate := fmt.Sprintf(`
resource "redshift_group" "update_group" {
name = "update_group"
name = %[1]q
}
`
`, groupName)

var configUpdate = `
configUpdate := fmt.Sprintf(`
resource "redshift_user" "group_update_user1" {
name = "group_update_user1"
name = %[1]q
}

resource "redshift_user" "group_update_user2" {
name = "group_update_user2"
name = %[2]q
}

resource "redshift_group" "update_group" {
name = "update_group2"
name = %[3]q
users = [
redshift_user.group_update_user1.name,
redshift_user.group_update_user2.name,
]
}
`
`, userName1, userName2, groupNameUpdated)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Expand All @@ -71,25 +75,27 @@ resource "redshift_group" "update_group" {
{
Config: configCreate,
Check: resource.ComposeTestCheckFunc(
testAccCheckRedshiftGroupExists("update_group"),
resource.TestCheckResourceAttr("redshift_group.update_group", "name", "update_group"),
testAccCheckRedshiftGroupExists(groupName),
resource.TestCheckResourceAttr("redshift_group.update_group", "name", strings.ToLower(groupName)),
resource.TestCheckResourceAttr("redshift_group.update_group", "users.#", "0"),
),
},
{
Config: configUpdate,
Check: resource.ComposeTestCheckFunc(
testAccCheckRedshiftGroupExists("update_group2"),
resource.TestCheckResourceAttr("redshift_group.update_group", "name", "update_group2"),
testAccCheckRedshiftGroupExists(groupNameUpdated),
resource.TestCheckResourceAttr("redshift_group.update_group", "name", strings.ToLower(groupNameUpdated)),
resource.TestCheckResourceAttr("redshift_group.update_group", "users.#", "2"),
resource.TestCheckTypeSetElemAttr("redshift_group.update_group", "users.*", userName1),
resource.TestCheckTypeSetElemAttr("redshift_group.update_group", "users.*", userName2),
),
},
// apply the first one again to check if all parameters roll back properly
{
Config: configCreate,
Check: resource.ComposeTestCheckFunc(
testAccCheckRedshiftGroupExists("update_group"),
resource.TestCheckResourceAttr("redshift_group.update_group", "name", "update_group"),
testAccCheckRedshiftGroupExists(groupName),
resource.TestCheckResourceAttr("redshift_group.update_group", "name", strings.ToLower(groupName)),
resource.TestCheckResourceAttr("redshift_group.update_group", "users.#", "0"),
),
},
Expand Down Expand Up @@ -176,7 +182,7 @@ resource "redshift_group" "group_users" {
}

resource "redshift_user" "group_test_user1" {
name = "group_test_user1"
name = "GROUP_TEST_USER1"
}

resource "redshift_user" "group_test_user2" {
Expand Down