Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabianoshz committed Nov 26, 2024
1 parent 23ad8c2 commit bde91d0
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions postgresql/resource_postgresql_event_trigger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,19 @@ func TestAccPostgresqlEventTrigger_Basic(t *testing.T) {

dbName, _ := getTestDBNames(dbSuffix)

testAccPostgresqlDataSourceTablesEventTriggerConfig := fmt.Sprintf(testAccPostgreSQLEventTriggerConfig, dbName, schemas[0])

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckPostgresqlEventTriggerDestroy,
Steps: []resource.TestStep{
{
Config: testAccPostgresqlDataSourceTablesEventTriggerConfig,
Config: fmt.Sprintf(testAccPostgreSQLEventTriggerConfig, dbName, schemas[0], "test_event"),
Check: resource.ComposeTestCheckFunc(
testAccCheckPostgresqlEventTriggerExists("postgresql_event_trigger.event_trigger", dbName),
),
},
{
Config: fmt.Sprintf(testAccPostgreSQLEventTriggerConfig, dbName, schemas[0], "test_event_renamed"),
Check: resource.ComposeTestCheckFunc(
testAccCheckPostgresqlEventTriggerExists("postgresql_event_trigger.event_trigger", dbName),
),
Expand All @@ -58,7 +62,7 @@ func testAccCheckPostgresqlEventTriggerExists(n string, database string) resourc
}
defer deferredRollback(txn)

exists, err := checkEventTriggerExists(txn, rs.Primary.ID)
exists, err := checkEventTriggerExists(txn, rs.Primary.Attributes["name"])

if err != nil {
return fmt.Errorf("Error checking event trigger %s", err)
Expand Down Expand Up @@ -93,7 +97,7 @@ func testAccCheckPostgresqlEventTriggerDestroy(s *terraform.State) error {
}
defer deferredRollback(txn)

exists, err := checkEventTriggerExists(txn, rs.Primary.ID)
exists, err := checkEventTriggerExists(txn, rs.Primary.Attributes["name"])

if err != nil {
return fmt.Errorf("Error checking event trigger %s", err)
Expand Down Expand Up @@ -136,7 +140,7 @@ resource "postgresql_function" "function" {
}
resource "postgresql_event_trigger" "event_trigger" {
name = "event_trigger_test"
name = "%[3]s"
database = "%[1]s"
function = postgresql_function.function.name
function_schema = postgresql_function.function.schema
Expand Down

0 comments on commit bde91d0

Please sign in to comment.