diff --git a/tests/postgres/postgres_integration_test.go b/tests/postgres/postgres_integration_test.go index 1146d14d17..f554e3ff39 100644 --- a/tests/postgres/postgres_integration_test.go +++ b/tests/postgres/postgres_integration_test.go @@ -92,19 +92,23 @@ func TestPostgres(t *testing.T) { if err != nil { t.Fatalf("unable to create postgres connection pool: %s", err) } - t.Fatalf("force failure") // cleanup test environment // tests.CleanupPostgresTables(t, ctx, pool) - + t.Cleanup(func() { + fmt.Println("this is executed after the failure"); + tests.CleanupPostgresTables(t, context.Background(), pool) + }) + // create table name with UUID tableNameParam := "param_table_" + strings.ReplaceAll(uuid.New().String(), "-", "") tableNameAuth := "auth_table_" + strings.ReplaceAll(uuid.New().String(), "-", "") tableNameTemplateParam := "template_param_table_" + strings.ReplaceAll(uuid.New().String(), "-", "") - + // set up data for param tool createParamTableStmt, insertParamTableStmt, paramToolStmt, idParamToolStmt, nameParamToolStmt, arrayToolStmt, paramTestParams := tests.GetPostgresSQLParamToolInfo(tableNameParam) teardownTable1 := tests.SetupPostgresSQLTable(t, ctx, pool, createParamTableStmt, insertParamTableStmt, tableNameParam, paramTestParams) + t.Fatalf("force failure") defer teardownTable1(t) // set up data for auth tool @@ -116,10 +120,6 @@ func TestPostgres(t *testing.T) { vectorTableName, tearDownVectorTable := tests.SetupPostgresVectorTable(t, ctx, pool) defer tearDownVectorTable(t) - t.Cleanup(func() { - fmt.Println("this is executed after the failure"); - tests.CleanupPostgresTables(t, context.Background(), pool) - }) // Write config into a file and pass it to command toolsFile := tests.GetToolsConfig(sourceConfig, PostgresToolType, paramToolStmt, idParamToolStmt, nameParamToolStmt, arrayToolStmt, authToolStmt) toolsFile = tests.AddExecuteSqlConfig(t, toolsFile, "postgres-execute-sql")