mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-01-10 07:58:12 -05:00
test
This commit is contained in:
@@ -446,10 +446,16 @@ func runToolAggregateInvokeTest(t *testing.T, aggregate1Want string, aggregateMa
|
||||
func setupMongoDB(t *testing.T, ctx context.Context, database *mongo.Database) func(*testing.T) {
|
||||
collectionName := "test_collection"
|
||||
|
||||
//Ensure the collection is clean
|
||||
if err := database.Collection(collectionName).Drop(ctx); err != nil {
|
||||
t.Logf("Warning: failed to drop collection before setup: %v", err)
|
||||
}
|
||||
|
||||
// Drop the target collection used in aggregate tests
|
||||
if err := database.Collection("target_collection").Drop(ctx); err != nil {
|
||||
t.Logf("Warning: failed to drop target collection before setup: %v", err)
|
||||
}
|
||||
|
||||
documents := []map[string]any{
|
||||
{"_id": 1, "id": 1, "name": "Alice", "email": ServiceAccountEmail},
|
||||
{"_id": 14, "id": 2, "name": "FakeAlice", "email": "fakeAlice@gmail.com"},
|
||||
|
||||
@@ -93,7 +93,7 @@ func TestPostgres(t *testing.T) {
|
||||
t.Fatalf("unable to create postgres connection pool: %s", err)
|
||||
}
|
||||
|
||||
// cleanup test environment
|
||||
// cleanup the collections
|
||||
tests.CleanupPostgresTables(t, ctx, pool)
|
||||
|
||||
// create table name with UUID
|
||||
|
||||
@@ -660,7 +660,7 @@ func runCancelBatchTest(t *testing.T, client *dataproc.BatchControllerClient, ct
|
||||
}
|
||||
|
||||
if batch.State != dataprocpb.Batch_SUCCEEDED {
|
||||
waitForBatch(t, client, ctx, batchName, []dataprocpb.Batch_State{dataprocpb.Batch_CANCELLING, dataprocpb.Batch_CANCELLED}, 2*time.Minute)
|
||||
waitForBatch(t, client, ctx, batchName, []dataprocpb.Batch_State{dataprocpb.Batch_CANCELLING, dataprocpb.Batch_CANCELLED}, 5*time.Minute)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,12 @@ func setupSingleStoreTable(t *testing.T, ctx context.Context, pool *sql.DB, crea
|
||||
if err != nil {
|
||||
t.Fatalf("unable to connect to test database: %s", err)
|
||||
}
|
||||
|
||||
// Safety drop before creation
|
||||
_, err = pool.ExecContext(ctx, fmt.Sprintf("DROP TABLE IF EXISTS %s;", tableName))
|
||||
if err != nil {
|
||||
t.Fatalf("Warning: failed to drop table %s before creation:%v ",tableName,err)
|
||||
}
|
||||
|
||||
// Create table
|
||||
_, err = pool.QueryContext(ctx, createStatement)
|
||||
if err != nil {
|
||||
|
||||
@@ -163,9 +163,15 @@ func setupTrinoTable(t *testing.T, ctx context.Context, pool *sql.DB, createStat
|
||||
if err != nil {
|
||||
t.Fatalf("unable to connect to test database: %s", err)
|
||||
}
|
||||
//Ensure the collection is clean
|
||||
_, err = pool.ExecContext(ctx, fmt.Sprintf("DROP TABLE IF EXISTS %s", tableName))
|
||||
if err!=nil {
|
||||
t.Logf("Warning: failed to drop existing table %s",tableName)
|
||||
}
|
||||
|
||||
// Create table
|
||||
_, err = pool.QueryContext(ctx, createStatement)
|
||||
_, err = pool.ExecContext(ctx, createStatement)
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create test table %s: %s", tableName, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user