Skip to content

Commit

Permalink
add regression test from @crosbymichael
Browse files Browse the repository at this point in the history
  • Loading branch information
vieux committed Jul 19, 2013
1 parent a0eec14 commit 2b5386f
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

0 comments on commit 2b5386f

Please sign in to comment.