-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pkg/pg with dialects.go & txdb.go #910
base: main
Are you sure you want to change the base?
Conversation
Neither of these were in the actual pg package in chainlink repo. dialects.go came from core/store/dialects and txdb.go from core/internal/testutils/pgtest, but neither of these seem like they deserve their own package in chainlink-common--we can lump all the postgres specific common utilities under pkg/pg
86478ad
to
8e479fe
Compare
Also: convert rest of panic isn't ordinary errors
213ae02
to
9035c2a
Compare
tests.SkipShortDB(t) | ||
err := RegisterTxDb(dbURL) | ||
if err != nil { | ||
t.Errorf("failed to register txdb dialect: %s", err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should not this be a fatal error?
Otherwise caller has to check if returned db is nil.
func TestTxDBDriver(t *testing.T) { | ||
dbURL, ok := os.LookupEnv("CL_DATABASE_URL") | ||
require.True(t, ok, "CL_DATABASE_URL must be set") | ||
db := NewSqlxDB(t, dbURL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've noticed weird behavior in my PR. If two tests use db and run sequentially, second fails with conn closed
error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I think I know why that's happening. I changed txdb to use the test context for queries instead of context.Background
, thinking that was an improvement over what's currently in chainlink
repo. But apparently that won't work--we'll have to put it back to context.Background
, I guess there's just no context that would survive long enough for this.
NONEVM-739
Supports
smartcontractkit/chainlink#15064
smartcontractkit/chainlink-solana#921
Neither of these were in the actual pg package in chainlink repo. dialects.go came from core/store/dialects and txdb.go from core/internal/testutils/pgtest, but neither of these seem like they deserve their own package in chainlink-common--we can lump all the postgres specific common utilities under pkg/pg (TODO: change to pkg/sqlutils/pg to match Jordan's PR]