clear sqlx db
All checks were successful
Test / Run compliance tests (pull_request) Successful in 4m37s
Test / Run unit tests (pull_request) Successful in 12m46s
Test / Run integration tests (pull_request) Successful in 28m35s

This commit is contained in:
Roy Crihfield 2024-07-11 16:33:43 +08:00
parent 75701bb45c
commit 6fe622e4bf

View File

@ -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)