mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-01-11 16:38:15 -05:00
Compare commits
12 Commits
source-imp
...
integratio
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de6b78366e | ||
|
|
35811a833b | ||
|
|
eeedc4b059 | ||
|
|
e66deb9abf | ||
|
|
c60a4af1ea | ||
|
|
71fdcd2ac8 | ||
|
|
3466e1459e | ||
|
|
fba3091f9e | ||
|
|
efbde0dcb1 | ||
|
|
bb24e03475 | ||
|
|
f73d466f74 | ||
|
|
f8f4c10d35 |
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +109,11 @@ func setupSingleStoreTable(t *testing.T, ctx context.Context, pool *sql.DB, crea
|
||||
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 {
|
||||
|
||||
@@ -27,7 +27,6 @@ import (
|
||||
"github.com/google/uuid"
|
||||
"github.com/googleapis/genai-toolbox/internal/testutils"
|
||||
"github.com/googleapis/genai-toolbox/tests"
|
||||
_ "github.com/trinodb/trino-go-client/trino" // Import Trino SQL driver
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -163,15 +162,21 @@ 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)
|
||||
}
|
||||
|
||||
// Insert test data
|
||||
_, err = pool.QueryContext(ctx, insertStatement, params...)
|
||||
_, err = pool.ExecContext(ctx, insertStatement, params...)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to insert test data: %s", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user