Skip to content

Commit

Permalink
Move txdb.go and dialects.go to chainlink-common
Browse files Browse the repository at this point in the history
  • Loading branch information
reductionista committed Nov 1, 2024
1 parent 38ef179 commit 7755dcd
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 532 deletions.
11 changes: 9 additions & 2 deletions core/internal/testutils/pgtest/pgtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,22 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink-common/pkg/pg"
"github.com/smartcontractkit/chainlink-common/pkg/sqlutil"
"github.com/smartcontractkit/chainlink-common/pkg/utils"

"github.com/smartcontractkit/chainlink/v2/core/config/env"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils"
"github.com/smartcontractkit/chainlink/v2/core/store/dialects"
)

func NewSqlxDB(t testing.TB) *sqlx.DB {
testutils.SkipShortDB(t)
db, err := sqlx.Open(string(dialects.TransactionWrappedPostgres), uuid.New().String())
dbURL := string(env.DatabaseURL.Get())
if dbURL == "" {
panic("you must provide a CL_DATABASE_URL environment variable")
}
pg.RegisterTxDb(dbURL)
db, err := sqlx.Open(string(pg.TransactionWrappedPostgres), uuid.New().String())
require.NoError(t, err)
t.Cleanup(func() { assert.NoError(t, db.Close()) })
db.MapperFunc(reflectx.CamelToSnakeASCII)
Expand Down
Loading

0 comments on commit 7755dcd

Please sign in to comment.