mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
add regression test from @crosbymichael
This commit is contained in:
parent
a0eec14c7d
commit
2b5386f039
1 changed files with 42 additions and 0 deletions
|
@ -190,3 +190,45 @@ func TestMergeConfig(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMergeConfigPublicPortNotHonored(t *testing.T) {
|
||||||
|
volumesImage := make(map[string]struct{})
|
||||||
|
volumesImage["/test1"] = struct{}{}
|
||||||
|
volumesImage["/test2"] = struct{}{}
|
||||||
|
configImage := &Config{
|
||||||
|
Dns: []string{"1.1.1.1", "2.2.2.2"},
|
||||||
|
PortSpecs: []string{"1111", "2222"},
|
||||||
|
Env: []string{"VAR1=1", "VAR2=2"},
|
||||||
|
Volumes: volumesImage,
|
||||||
|
}
|
||||||
|
|
||||||
|
volumesUser := make(map[string]struct{})
|
||||||
|
volumesUser["/test3"] = struct{}{}
|
||||||
|
configUser := &Config{
|
||||||
|
Dns: []string{"3.3.3.3"},
|
||||||
|
PortSpecs: []string{"1111:3333"},
|
||||||
|
Env: []string{"VAR2=3", "VAR3=3"},
|
||||||
|
Volumes: volumesUser,
|
||||||
|
}
|
||||||
|
|
||||||
|
MergeConfig(configUser, configImage)
|
||||||
|
|
||||||
|
contains := func(a []string, expect string) bool {
|
||||||
|
for _, p := range a {
|
||||||
|
if p == expect {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if !contains(configUser.PortSpecs, "2222") {
|
||||||
|
t.Logf("Expected '2222' Ports: %v", configUser.PortSpecs)
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
|
||||||
|
if !contains(configUser.PortSpecs, "1111:3333") {
|
||||||
|
t.Logf("Expected '1111:3333' Ports: %v", configUser.PortSpecs)
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue