diff --git a/builtin/logical/postgresql/backend_test.go b/builtin/logical/postgresql/backend_test.go index e34b6dc34d..a16cb2646a 100644 --- a/builtin/logical/postgresql/backend_test.go +++ b/builtin/logical/postgresql/backend_test.go @@ -105,7 +105,7 @@ func testAccStepReadCreds(t *testing.T, b logical.Backend, name string) logicalt returnedRows := func() int { stmt, err := db.Prepare(fmt.Sprintf( - "SELECT DISTINCT table_schema FROM information_schema.role_column_grants WHERE grantee='%s';", + "SELECT DISTINCT schemaname FROM pg_tables WHERE has_table_privilege('%s', 'information_schema.role_column_grants', 'select');", d.Username)) if err != nil { return -1 @@ -126,7 +126,7 @@ func testAccStepReadCreds(t *testing.T, b logical.Backend, name string) logicalt } userRows := returnedRows() - if userRows != 1 { + if userRows != 2 { t.Fatalf("did not get expected number of rows, got %d", userRows) } @@ -149,7 +149,8 @@ func testAccStepReadCreds(t *testing.T, b logical.Backend, name string) logicalt } userRows = returnedRows() - if userRows != 0 { + // User shouldn't exist so returnedRows() should encounter an error and exit with -1 + if userRows != -1 { t.Fatalf("did not get expected number of rows, got %d", userRows) }