From 6fe622e4bf331c02caaec0dd0ffe4b158613ac12 Mon Sep 17 00:00:00 2001 From: Roy Crihfield Date: Thu, 11 Jul 2024 16:33:43 +0800 Subject: [PATCH] clear sqlx db --- indexer/test_helpers/test_helpers.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/indexer/test_helpers/test_helpers.go b/indexer/test_helpers/test_helpers.go index 6a4da69..ee71cb5 100644 --- a/indexer/test_helpers/test_helpers.go +++ b/indexer/test_helpers/test_helpers.go @@ -24,7 +24,9 @@ import ( "testing" "github.com/cerc-io/plugeth-statediff/indexer/database/sql" + "github.com/cerc-io/plugeth-statediff/indexer/database/sql/postgres" "github.com/cerc-io/plugeth-statediff/indexer/shared/schema" + "github.com/jmoiron/sqlx" ) // DedupFile removes duplicates from the given file @@ -65,6 +67,12 @@ func TearDownDB(t *testing.T, db sql.Database) { } } +func ClearSqlxDB(sqlxdb *sqlx.DB) error { + driver := postgres.NewSQLXDriver(context.Background(), sqlxdb) + db := postgres.NewPostgresDB(driver, false) + return ClearDB(db) +} + func ClearDB(db sql.Database) error { ctx := context.Background() tx, err := db.Begin(ctx)