Removing the container after running script check

This commit is contained in:
Diptanu Choudhury 2016-03-25 17:02:53 -07:00
parent 44a3f2ae1f
commit 439a86f194

View file

@ -119,6 +119,7 @@ func TestDockerScriptCheck(t *testing.T) {
if err != nil {
t.Fatalf("error creating container: %v", err)
}
defer removeContainer(client, container.ID)
if err := client.StartContainer(container.ID, &docker.HostConfig{}); err != nil {
t.Fatalf("error starting container", err)
@ -147,3 +148,9 @@ func TestDockerScriptCheck(t *testing.T) {
t.Fatalf("exitcode expected: %v, actual: %v", expectedExitCode, res.ExitCode)
}
}
// removeContainer kills and removes a container
func removeContainer(client *docker.Client, containerID string) {
client.KillContainer(docker.KillContainerOptions{ID: containerID})
client.RemoveContainer(docker.RemoveContainerOptions{ID: containerID, Force: true})
}