mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-02-03 03:35:02 -05:00
Compare commits
4 Commits
refactor-t
...
temp-Delet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff874ef385 | ||
|
|
a6335c3797 | ||
|
|
63cdea2cd0 | ||
|
|
a18fe045dd |
@@ -614,6 +614,8 @@ func GetMySQLWants() (string, string, string, string) {
|
|||||||
// SetupPostgresSQLTable creates and inserts data into a table of tool
|
// SetupPostgresSQLTable creates and inserts data into a table of tool
|
||||||
// compatible with postgres-sql tool
|
// compatible with postgres-sql tool
|
||||||
func SetupPostgresSQLTable(t *testing.T, ctx context.Context, pool *pgxpool.Pool, createStatement, insertStatement, tableName string, params []any) func(*testing.T) {
|
func SetupPostgresSQLTable(t *testing.T, ctx context.Context, pool *pgxpool.Pool, createStatement, insertStatement, tableName string, params []any) func(*testing.T) {
|
||||||
|
|
||||||
|
|
||||||
err := pool.Ping(ctx)
|
err := pool.Ping(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to connect to test database: %s", err)
|
t.Fatalf("unable to connect to test database: %s", err)
|
||||||
@@ -621,9 +623,10 @@ func SetupPostgresSQLTable(t *testing.T, ctx context.Context, pool *pgxpool.Pool
|
|||||||
|
|
||||||
// Create table
|
// Create table
|
||||||
_, err = pool.Query(ctx, createStatement)
|
_, err = pool.Query(ctx, createStatement)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
t.Fatalf("unable to create test table %s: %s", tableName, err)
|
// t.Fatalf("unable to create test table %s: %s", tableName, err)
|
||||||
}
|
// }
|
||||||
|
t.Fatalf("unable to create test table %s: %s", tableName, err)
|
||||||
|
|
||||||
// Insert test data
|
// Insert test data
|
||||||
_, err = pool.Query(ctx, insertStatement, params...)
|
_, err = pool.Query(ctx, insertStatement, params...)
|
||||||
|
|||||||
@@ -92,15 +92,18 @@ func TestPostgres(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to create postgres connection pool: %s", err)
|
t.Fatalf("unable to create postgres connection pool: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// cleanup test environment
|
// cleanup test environment
|
||||||
tests.CleanupPostgresTables(t, ctx, pool)
|
// tests.CleanupPostgresTables(t, ctx, pool)
|
||||||
|
t.Cleanup(func() {
|
||||||
|
tests.CleanupPostgresTables(t, context.Background(), pool)
|
||||||
|
})
|
||||||
|
|
||||||
// create table name with UUID
|
// create table name with UUID
|
||||||
tableNameParam := "param_table_" + strings.ReplaceAll(uuid.New().String(), "-", "")
|
tableNameParam := "param_table_" + strings.ReplaceAll(uuid.New().String(), "-", "")
|
||||||
tableNameAuth := "auth_table_" + strings.ReplaceAll(uuid.New().String(), "-", "")
|
tableNameAuth := "auth_table_" + strings.ReplaceAll(uuid.New().String(), "-", "")
|
||||||
tableNameTemplateParam := "template_param_table_" + strings.ReplaceAll(uuid.New().String(), "-", "")
|
tableNameTemplateParam := "template_param_table_" + strings.ReplaceAll(uuid.New().String(), "-", "")
|
||||||
|
|
||||||
// set up data for param tool
|
// set up data for param tool
|
||||||
createParamTableStmt, insertParamTableStmt, paramToolStmt, idParamToolStmt, nameParamToolStmt, arrayToolStmt, paramTestParams := tests.GetPostgresSQLParamToolInfo(tableNameParam)
|
createParamTableStmt, insertParamTableStmt, paramToolStmt, idParamToolStmt, nameParamToolStmt, arrayToolStmt, paramTestParams := tests.GetPostgresSQLParamToolInfo(tableNameParam)
|
||||||
teardownTable1 := tests.SetupPostgresSQLTable(t, ctx, pool, createParamTableStmt, insertParamTableStmt, tableNameParam, paramTestParams)
|
teardownTable1 := tests.SetupPostgresSQLTable(t, ctx, pool, createParamTableStmt, insertParamTableStmt, tableNameParam, paramTestParams)
|
||||||
|
|||||||
Reference in New Issue
Block a user