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
chore(test): use testcontainers modules #1164
Conversation
Codecov ReportPatch has no changes to coverable lines. 📢 Thoughts on this report? Let us know!. |
12e221b
to
618cc87
Compare
618cc87
to
2585fd1
Compare
testcontainers.WithWaitStrategy( | ||
wait.ForLog("database system is ready to accept connections"). | ||
WithOccurrence(waitLogOccurrence). | ||
WithStartupTimeout(startupTimeout)), |
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 was wondering why this is the only one using WithWaitStrategy
and from looking at testcontainers
code, the others have one built-in.
Might be worth making an issue/PR to add a built-in one for postgres too since the others also use log matching, so there's no reason this couldn't be built-in.
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.
Yes, I have also noticed that. In official example for postgres (https://golang.testcontainers.org/modules/postgres/) is a wait strategy defined. In redis and mariaDB not.
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.
Found this comment: testcontainers/testcontainers-go#1619 (comment)
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.
Nice find, glad they're thinking of it.
ExposedPorts: []string{"6379/tcp"}, | ||
NetworkAliases: map[string][]string{NetworkName: {"redis"}}, | ||
WaitingFor: wait.ForExposedPort(), | ||
func WithNetwork(network string) testcontainers.CustomizeRequestOption { |
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.
FYI we have just added a WithNetwork
option here: testcontainers/testcontainers-go#1894
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.
Thanks, this is very cool, I'll change our implementation 🤝
testcontainers provides predefined containers for major databases. This PR replaces mariadb, postgeres and redis with testcontainers modules.