Misleading example in readme
rgarrigue opened this issue · 3 comments
Hello
Reading the doc, I banged my head a while (on a difficult monday morning) about https://github.com/palantir/docker-compose-rule#waiting-for-a-service-to-be-available: You should either include toBeOpen() in the snippet or give it a completely different name like CustomDifferentCheckPortFunction(). Though it was part of the lib, like toHaveAllPortsOpen :-)
Best regards,
Thanks for the input @rgarrigue,
Would it make more sense to have it explicitly state the full path of the static import, instead of being implicit?
For example:
.waitingForHostNetworkedPort(5432, HostNetworkedPortsIntegrationTest.toBeOpen())
instead of the current:
.waitingForHostNetworkedPort(5432, toBeOpen())
Or was it something else you were referring too?
I guess that example can be confusion since the toBeOpen()
method is actually private
, and making it public
would probably also alleviate this confusion, but please chime in if that doesn't make sense.
Hi
Anything that would make this less misleading would to, full path or another name.
Thinking about it, the best way to be sure one can get something working is to give a full example. Maybe you can add to you repository a examples/ directory with the full code for your example, so one can copy/paste a working code and adapt it to one needs.
Anyway, the doc is already quite verbose, quite good. Thanks for that :-)
Yeah took me a while to understand toBeOpen() isn't available,
for the rest, just copy paste this:
private static HealthCheck<DockerPort> toBeOpen() {
return port -> SuccessOrFailure.fromBoolean(port.isListeningNow(), "Internal port " + port + " was not listening");
}
imports:
import com.palantir.docker.compose.DockerComposeRule;
import com.palantir.docker.compose.connection.DockerPort;
import com.palantir.docker.compose.connection.waiting.HealthCheck;
import com.palantir.docker.compose.connection.waiting.SuccessOrFailure;
import org.junit.ClassRule;
import org.junit.jupiter.api.Test;