mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-02-02 19:24:59 -05:00
testing t.cleanup
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user