Skip to content

Commit

Permalink
fixup! feat: Postgresql 15 support
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrilgdn committed Sep 9, 2023
1 parent f9cc215 commit 3e6c7bc
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions postgresql/resource_postgresql_grant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1348,24 +1348,6 @@ func TestAccPostgresqlGrantOwnerPG15(t *testing.T) {

dbName, roleName := getTestDBNames(dbSuffix)

config := getTestConfig(t)
db, err := sql.Open("postgres", config.connStr(dbName))
if err != nil {
t.Fatalf("could not connect to database %s: %v", dbName, err)
}

defer db.Close()
// time.Sleep(120 * time.Second)

// Set the owner to the new pg_database_owner role
if _, err := db.Exec(`
ALTER SCHEMA test_schema OWNER TO pg_database_owner;
ALTER TABLE test_schema.test_table OWNER TO pg_database_owner;
`,
); err != nil {
t.Fatalf("could not alter owner of test_table (as %s): %v", config.Username, err)
}

var tfConfig = fmt.Sprintf(`
resource "postgresql_grant" "test" {
database = "%s"
Expand All @@ -1379,6 +1361,25 @@ ALTER TABLE test_schema.test_table OWNER TO pg_database_owner;
PreCheck: func() {
testAccPreCheck(t)
testCheckCompatibleVersion(t, featureDatabaseOwnerRole)

// Change the owner to the new pg_database_owner role
func() {
config := getTestConfig(t)
db, err := sql.Open("postgres", config.connStr(dbName))
if err != nil {
t.Fatalf("could not connect to database %s: %v", dbName, err)
}

defer db.Close()

if _, err := db.Exec(`
ALTER SCHEMA test_schema OWNER TO pg_database_owner;
ALTER TABLE test_schema.test_table OWNER TO pg_database_owner;
`); err != nil {
t.Fatalf("could not alter owner of test_table (as %s): %v", config.Username, err)
}

}()
},
Providers: testAccProviders,
Steps: []resource.TestStep{
Expand Down

0 comments on commit 3e6c7bc

Please sign in to comment.