|
@@ -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()
|
|
|
+ }
|
|
|
+}
|