testing the t.cleanup ends where

This commit is contained in:
rahulpinto19
2026-02-02 11:00:22 +00:00
parent e0245946ea
commit a18fe045dd

View File

@@ -92,9 +92,10 @@ 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)
// tests.CleanupPostgresTables(t, ctx, pool)
// create table name with UUID
tableNameParam := "param_table_" + strings.ReplaceAll(uuid.New().String(), "-", "")
@@ -115,6 +116,10 @@ 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")