Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
| ... | ... |
@@ -122,16 +122,31 @@ func TestInspectLinksStarted(t *testing.T) {
|
| 122 | 122 |
} |
| 123 | 123 |
|
| 124 | 124 |
func TestInspectLinksStopped(t *testing.T) {
|
| 125 |
+ var ( |
|
| 126 |
+ expected = map[string]struct{}{"/container1:/testinspectlink/alias1": {}, "/container2:/testinspectlink/alias2": {}}
|
|
| 127 |
+ result []string |
|
| 128 |
+ ) |
|
| 125 | 129 |
defer deleteAllContainers() |
| 126 | 130 |
cmd(t, "run", "-d", "--name", "container1", "busybox", "sleep", "10") |
| 127 | 131 |
cmd(t, "run", "-d", "--name", "container2", "busybox", "sleep", "10") |
| 128 | 132 |
cmd(t, "run", "-d", "--name", "testinspectlink", "--link", "container1:alias1", "--link", "container2:alias2", "busybox", "true") |
| 129 |
- links, err := inspectField("testinspectlink", "HostConfig.Links")
|
|
| 133 |
+ links, err := inspectFieldJSON("testinspectlink", "HostConfig.Links")
|
|
| 130 | 134 |
if err != nil {
|
| 131 | 135 |
t.Fatal(err) |
| 132 | 136 |
} |
| 133 |
- if expected := "[/container1:/testinspectlink/alias1 /container2:/testinspectlink/alias2]"; links != expected {
|
|
| 134 |
- t.Fatalf("Links %s, but expected %s", links, expected)
|
|
| 137 |
+ |
|
| 138 |
+ err = unmarshalJSON([]byte(links), &result) |
|
| 139 |
+ if err != nil {
|
|
| 140 |
+ t.Fatal(err) |
|
| 135 | 141 |
} |
| 142 |
+ |
|
| 143 |
+ output := convertSliceOfStringsToMap(result) |
|
| 144 |
+ |
|
| 145 |
+ equal := deepEqual(expected, output) |
|
| 146 |
+ |
|
| 147 |
+ if !equal {
|
|
| 148 |
+ t.Fatalf("Links %s, but expected %s", result, expected)
|
|
| 149 |
+ } |
|
| 150 |
+ |
|
| 136 | 151 |
logDone("link - links in stopped container inspect")
|
| 137 | 152 |
} |