Commit a587be44 authored by Danielle Tomlinson's avatar Danielle Tomlinson
Browse files

dockerlogger: Fix tests on windows

Uses the home directory and windows path expansion, as c:\tmp doesn't
necessarily exist, and mktemp would involve unnecessarily complicating
the commands.
Showing with 25 additions and 7 deletions
+25 -7
......@@ -24,11 +24,11 @@ func TestDockerLogger(t *testing.T) {
t.Skip("docker unavailable:", err)
}
if img, err := client.InspectImage("busybox:1"); err != nil || img == nil {
if img, err := client.InspectImage(containerImage); err != nil || img == nil {
t.Log("image not found locally, downloading...")
err = client.PullImage(docker.PullImageOptions{
Repository: "busybox",
Tag: "1",
Repository: containerImageName,
Tag: containerImageTag,
}, docker.AuthConfiguration{})
if err != nil {
t.Fatalf("failed to pull image: %v", err)
......@@ -38,9 +38,9 @@ func TestDockerLogger(t *testing.T) {
containerConf := docker.CreateContainerOptions{
Config: &docker.Config{
Cmd: []string{
"/bin/sh", "-c", "touch /tmp/docklog; tail -f /tmp/docklog",
"sh", "-c", "touch ~/docklog; tail -f ~/docklog",
},
Image: "busybox:1",
Image: containerImage,
},
Context: context.Background(),
}
......@@ -98,8 +98,8 @@ func echoToContainer(t *testing.T, client *docker.Client, id string, line string
op := docker.CreateExecOptions{
Container: id,
Cmd: []string{
"/bin/ash", "-c",
fmt.Sprintf("echo %s >>/tmp/docklog", line),
"ash", "-c",
fmt.Sprintf("echo %s >>~/docklog", line),
},
}
......
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
package docklog
var (
containerImage = "busybox:1"
containerImageName = "busybox"
containerImageTag = "1"
)
// +build windows
package docklog
var (
containerImage = "dantoml/busybox-windows:08012019"
containerImageName = "dantoml/busybox-windows"
containerImageTag = "08012019"
)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment