Skip to content
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

Refactor tests to work with testcontainers #59

Merged
merged 7 commits into from
Jan 6, 2024
Merged

Refactor tests to work with testcontainers #59

merged 7 commits into from
Jan 6, 2024

Conversation

flimzy
Copy link
Collaborator

@flimzy flimzy commented Nov 23, 2023

No description provided.

@flimzy flimzy force-pushed the tests branch 10 times, most recently from 8fe15dd to db1b183 Compare November 29, 2023 21:12
@flimzy
Copy link
Collaborator Author

flimzy commented Nov 29, 2023

@Yiling-J Have a look. This is now working, though I have some additional cleanups to do before it's ready to merge. But I'm happy to get your preliminary thoughts.

No longer is the use of docker-compose needed for testing. Instead, for the simple case, simply run:

MYSQL_DSN=auto PSQL_DSN=auto go test ./...

If you want to use an existing, persistent, database (i.e. to avoid the startup time of a docker container for rapid testing), you can do that by providing the dsn:

MYSQL_DSN=root:pass@/ PSQL_DSN=postgres://postgres:pass@localhost/ go test ./...

Or if you want to test only against MySQL for example:

MYSQL_DSN=auto go test ./...

I've also updated CI to no longer use services in GitHub actions. While there's nothing wrong with that approach, I like excercising the testcontainers approach in CI as well, just to keep local and CI as similar as possible.

Curious to hear your reaction.

@flimzy flimzy changed the title Refactor tests Refactor tests to work with testcontainers Nov 29, 2023
@flimzy flimzy marked this pull request as ready for review January 4, 2024 22:08
@flimzy
Copy link
Collaborator Author

flimzy commented Jan 4, 2024

I just went through my PR agian, to look for any cleanups, and didn't find much more than some typo corrections and clarifications. I think this is ready for a proper review now.

@Yiling-J
Copy link
Collaborator

Yiling-J commented Jan 5, 2024

I just went through my PR agian, to look for any cleanups, and didn't find much more than some typo corrections and clarifications. I think this is ready for a proper review now.

lint failed because of golangci-lint version? I already merge that PR

@Yiling-J Yiling-J merged commit 8a12fdc into master Jan 6, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants