-
Notifications
You must be signed in to change notification settings - Fork 122
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
tapdb+mssmt: update mssmt unit tests to run against all registered db backends #770
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,6 +173,25 @@ func NewTestPostgresDB(t *testing.T) *PostgresStore { | |
return store | ||
} | ||
|
||
// NewPostgresDB is a helper function that creates a Postgres database for | ||
// testing. | ||
func NewPostgresDB() (*PostgresStore, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my other comment about moving the driver registration into a test file. Then we can perhaps create the empty There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah the I don't think we want to move the driver init into a test fie though, as this was created so we could write tests in the |
||
var t testing.T | ||
sqlFixture := NewTestPgFixture(&t, DefaultPostgresFixtureLifetime, true) | ||
if t.Failed() { | ||
return nil, fmt.Errorf("unable to make postgres db") | ||
} | ||
|
||
store, err := NewPostgresStore(sqlFixture.GetConfig()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// sqlFixture.TearDown(t) | ||
|
||
return store, nil | ||
} | ||
|
||
// NewTestPostgresDBWithVersion is a helper function that creates a Postgres | ||
// database for testing and migrates it to the given version. | ||
func NewTestPostgresDBWithVersion(t *testing.T, version uint) *PostgresStore { | ||
|
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 this really be in the non-test code? Since it's only used by unit tests and does spin up an ephemeral container in the Postgres case?
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.
Good point re test code vs non test code. I'd need to double check, but I don't think an
init
is run in a_test.go
when a package is imported.Re postgres container: this'll only happen if the
New
method of the driver is called (won't be created unconditionally).