Documentation
¶
Overview ¶
Opinionated ory/dockertest wrapper
Performs the following quality of life improvements:
• Build a Dockerfile
• Give it a unique name
• Expose its ports (like -P)
• Register it for purge if the test cleanup handlers run
• Wait for its health check to pass
• Configure the container to be auto-removed (like --rm)
IMPORTANT: You should use resource.Expire(seconds) to ensure that your returned resource is cleaned up in case of the test being killed. IMPORTANT: You _must_ configure a health check in your Dockerfile.
To use this for testing with a dockerfile which runs a webserver located at test/Dockerfile:
func TestSudoRun(t *testing.T) { resource := dockertesting.RunDockerfile(t, "test/Dockerfile") resource.Expire(300) hp := resource.GetHostPort("80/tcp") _, err := http.Get(hp) if err != nil { t.Fatalf("Failed to get from container: %v", err) } // when this closes, the container will be purged. }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunDockerfile ¶
Takes a testing.T and the filename of the Dockerfile.
Returns a docker resource
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.