-
Notifications
You must be signed in to change notification settings - Fork 17
Check for a label alongside of the server version #25
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
Changes from 1 commit
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 |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| import java.sql.PreparedStatement; | ||
| import java.sql.ResultSet; | ||
| import java.sql.SQLException; | ||
| import java.util.Arrays; | ||
|
|
||
| import com.github.dockerjava.api.DockerClient; | ||
| import com.github.dockerjava.api.model.Info; | ||
|
|
@@ -39,12 +40,19 @@ public void testcontainersCloudDockerEngine() { | |
| Info dockerInfo = client.infoCmd().exec(); | ||
|
|
||
| String serverVersion = dockerInfo.getServerVersion(); | ||
| assertThat(serverVersion) | ||
| String[] labels = dockerInfo.getLabels(); | ||
|
|
||
| boolean isCloudServer = labels != null && Arrays.asList(labels).contains("docker/cloud"); | ||
|
|
||
| if (!isCloudServer) { | ||
| assertThat(serverVersion) | ||
| .as("Docker Client is configured via the Testcontainers desktop app") | ||
| .satisfiesAnyOf( | ||
| dockerString -> assertThat(dockerString).contains("Testcontainers Desktop"), | ||
| dockerString -> assertThat(dockerString).contains("testcontainerscloud") | ||
|
||
| ); | ||
| ); | ||
| } | ||
|
|
||
|
|
||
| String runtimeName = "Testcontainers Cloud"; | ||
| if (!serverVersion.contains("testcontainerscloud")) { | ||
|
|
||
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.
It's generally a bad practice to have ifs in tests. Perhaps, we can design it as multiple tests and just skip those not matching preconditions?
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.
It was mostly an intermediate state situation while we are rolling the change out. But yes, I'm open to suggestions.
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.
Even for the intermediate step, it can be confusing. Also, it shares a bad message about our ways of doing tests this way. I'd vote for having separate tests for TCD connection and another for TCC at the end. But I need to experiment a bit with a zone that has the label first