mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
integcli: fix map randomization failures
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
This commit is contained in:
parent
e5e8669c72
commit
68bb56a4a5
2 changed files with 35 additions and 9 deletions
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
@ -592,8 +591,12 @@ func TestBuildRm(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestBuildWithVolumes(t *testing.T) {
|
||||
name := "testbuildvolumes"
|
||||
expected := "map[/test1:map[] /test2:map[]]"
|
||||
var (
|
||||
result map[string]map[string]struct{}
|
||||
name = "testbuildvolumes"
|
||||
emptyMap = make(map[string]struct{})
|
||||
expected = map[string]map[string]struct{}{"/test1": emptyMap, "/test2": emptyMap}
|
||||
)
|
||||
defer deleteImages(name)
|
||||
_, err := buildImage(name,
|
||||
`FROM scratch
|
||||
|
@ -603,13 +606,22 @@ func TestBuildWithVolumes(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
res, err := inspectField(name, "Config.Volumes")
|
||||
res, err := inspectFieldJSON(name, "Config.Volumes")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if res != expected {
|
||||
t.Fatalf("Volumes %s, expected %s", res, expected)
|
||||
|
||||
err = unmarshalJSON([]byte(res), &result)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
equal := deepEqual(&expected, &result)
|
||||
|
||||
if !equal {
|
||||
t.Fatalf("Volumes %s, expected %s", result, expected)
|
||||
}
|
||||
|
||||
logDone("build - with volumes")
|
||||
}
|
||||
|
||||
|
|
|
@ -93,16 +93,30 @@ func TestIpTablesRulesWhenLinkAndUnlink(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestInspectLinksStarted(t *testing.T) {
|
||||
var (
|
||||
expected = map[string]struct{}{"/container1:/testinspectlink/alias1": {}, "/container2:/testinspectlink/alias2": {}}
|
||||
result []string
|
||||
)
|
||||
defer deleteAllContainers()
|
||||
cmd(t, "run", "-d", "--name", "container1", "busybox", "sleep", "10")
|
||||
cmd(t, "run", "-d", "--name", "container2", "busybox", "sleep", "10")
|
||||
cmd(t, "run", "-d", "--name", "testinspectlink", "--link", "container1:alias1", "--link", "container2:alias2", "busybox", "sleep", "10")
|
||||
links, err := inspectField("testinspectlink", "HostConfig.Links")
|
||||
links, err := inspectFieldJSON("testinspectlink", "HostConfig.Links")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if expected := "[/container1:/testinspectlink/alias1 /container2:/testinspectlink/alias2]"; links != expected {
|
||||
t.Fatalf("Links %s, but expected %s", links, expected)
|
||||
|
||||
err = unmarshalJSON([]byte(links), &result)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
output := convertSliceOfStringsToMap(result)
|
||||
|
||||
equal := deepEqual(expected, output)
|
||||
|
||||
if !equal {
|
||||
t.Fatalf("Links %s, expected %s", result, expected)
|
||||
}
|
||||
logDone("link - links in started container inspect")
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue