|
@@ -163,32 +163,18 @@ func TestCompare(t *testing.T) {
|
|
volumes1 := make(map[string]struct{})
|
|
volumes1 := make(map[string]struct{})
|
|
volumes1["/test1"] = struct{}{}
|
|
volumes1["/test1"] = struct{}{}
|
|
config1 := Config{
|
|
config1 := Config{
|
|
- Dns: []string{"1.1.1.1", "2.2.2.2"},
|
|
|
|
- DnsSearch: []string{"foo", "bar"},
|
|
|
|
- PortSpecs: []string{"1111:1111", "2222:2222"},
|
|
|
|
- Env: []string{"VAR1=1", "VAR2=2"},
|
|
|
|
- VolumesFrom: "11111111",
|
|
|
|
- Volumes: volumes1,
|
|
|
|
- }
|
|
|
|
- config2 := Config{
|
|
|
|
- Dns: []string{"0.0.0.0", "2.2.2.2"},
|
|
|
|
- DnsSearch: []string{"foo", "bar"},
|
|
|
|
PortSpecs: []string{"1111:1111", "2222:2222"},
|
|
PortSpecs: []string{"1111:1111", "2222:2222"},
|
|
Env: []string{"VAR1=1", "VAR2=2"},
|
|
Env: []string{"VAR1=1", "VAR2=2"},
|
|
VolumesFrom: "11111111",
|
|
VolumesFrom: "11111111",
|
|
Volumes: volumes1,
|
|
Volumes: volumes1,
|
|
}
|
|
}
|
|
config3 := Config{
|
|
config3 := Config{
|
|
- Dns: []string{"1.1.1.1", "2.2.2.2"},
|
|
|
|
- DnsSearch: []string{"foo", "bar"},
|
|
|
|
PortSpecs: []string{"0000:0000", "2222:2222"},
|
|
PortSpecs: []string{"0000:0000", "2222:2222"},
|
|
Env: []string{"VAR1=1", "VAR2=2"},
|
|
Env: []string{"VAR1=1", "VAR2=2"},
|
|
VolumesFrom: "11111111",
|
|
VolumesFrom: "11111111",
|
|
Volumes: volumes1,
|
|
Volumes: volumes1,
|
|
}
|
|
}
|
|
config4 := Config{
|
|
config4 := Config{
|
|
- Dns: []string{"1.1.1.1", "2.2.2.2"},
|
|
|
|
- DnsSearch: []string{"foo", "bar"},
|
|
|
|
PortSpecs: []string{"0000:0000", "2222:2222"},
|
|
PortSpecs: []string{"0000:0000", "2222:2222"},
|
|
Env: []string{"VAR1=1", "VAR2=2"},
|
|
Env: []string{"VAR1=1", "VAR2=2"},
|
|
VolumesFrom: "22222222",
|
|
VolumesFrom: "22222222",
|
|
@@ -197,24 +183,11 @@ func TestCompare(t *testing.T) {
|
|
volumes2 := make(map[string]struct{})
|
|
volumes2 := make(map[string]struct{})
|
|
volumes2["/test2"] = struct{}{}
|
|
volumes2["/test2"] = struct{}{}
|
|
config5 := Config{
|
|
config5 := Config{
|
|
- Dns: []string{"1.1.1.1", "2.2.2.2"},
|
|
|
|
- DnsSearch: []string{"foo", "bar"},
|
|
|
|
PortSpecs: []string{"0000:0000", "2222:2222"},
|
|
PortSpecs: []string{"0000:0000", "2222:2222"},
|
|
Env: []string{"VAR1=1", "VAR2=2"},
|
|
Env: []string{"VAR1=1", "VAR2=2"},
|
|
VolumesFrom: "11111111",
|
|
VolumesFrom: "11111111",
|
|
Volumes: volumes2,
|
|
Volumes: volumes2,
|
|
}
|
|
}
|
|
- config6 := Config{
|
|
|
|
- Dns: []string{"1.1.1.1", "2.2.2.2"},
|
|
|
|
- DnsSearch: []string{"foos", "bars"},
|
|
|
|
- PortSpecs: []string{"1111:1111", "2222:2222"},
|
|
|
|
- Env: []string{"VAR1=1", "VAR2=2"},
|
|
|
|
- VolumesFrom: "11111111",
|
|
|
|
- Volumes: volumes1,
|
|
|
|
- }
|
|
|
|
- if Compare(&config1, &config2) {
|
|
|
|
- t.Fatalf("Compare should return false, Dns are different")
|
|
|
|
- }
|
|
|
|
if Compare(&config1, &config3) {
|
|
if Compare(&config1, &config3) {
|
|
t.Fatalf("Compare should return false, PortSpecs are different")
|
|
t.Fatalf("Compare should return false, PortSpecs are different")
|
|
}
|
|
}
|
|
@@ -224,9 +197,6 @@ func TestCompare(t *testing.T) {
|
|
if Compare(&config1, &config5) {
|
|
if Compare(&config1, &config5) {
|
|
t.Fatalf("Compare should return false, Volumes are different")
|
|
t.Fatalf("Compare should return false, Volumes are different")
|
|
}
|
|
}
|
|
- if Compare(&config1, &config6) {
|
|
|
|
- t.Fatalf("Compare should return false, DnsSearch are different")
|
|
|
|
- }
|
|
|
|
if !Compare(&config1, &config1) {
|
|
if !Compare(&config1, &config1) {
|
|
t.Fatalf("Compare should return true")
|
|
t.Fatalf("Compare should return true")
|
|
}
|
|
}
|
|
@@ -237,7 +207,6 @@ func TestMerge(t *testing.T) {
|
|
volumesImage["/test1"] = struct{}{}
|
|
volumesImage["/test1"] = struct{}{}
|
|
volumesImage["/test2"] = struct{}{}
|
|
volumesImage["/test2"] = struct{}{}
|
|
configImage := &Config{
|
|
configImage := &Config{
|
|
- Dns: []string{"1.1.1.1", "2.2.2.2"},
|
|
|
|
PortSpecs: []string{"1111:1111", "2222:2222"},
|
|
PortSpecs: []string{"1111:1111", "2222:2222"},
|
|
Env: []string{"VAR1=1", "VAR2=2"},
|
|
Env: []string{"VAR1=1", "VAR2=2"},
|
|
VolumesFrom: "1111",
|
|
VolumesFrom: "1111",
|
|
@@ -247,7 +216,6 @@ func TestMerge(t *testing.T) {
|
|
volumesUser := make(map[string]struct{})
|
|
volumesUser := make(map[string]struct{})
|
|
volumesUser["/test3"] = struct{}{}
|
|
volumesUser["/test3"] = struct{}{}
|
|
configUser := &Config{
|
|
configUser := &Config{
|
|
- Dns: []string{"2.2.2.2", "3.3.3.3"},
|
|
|
|
PortSpecs: []string{"3333:2222", "3333:3333"},
|
|
PortSpecs: []string{"3333:2222", "3333:3333"},
|
|
Env: []string{"VAR2=3", "VAR3=3"},
|
|
Env: []string{"VAR2=3", "VAR3=3"},
|
|
Volumes: volumesUser,
|
|
Volumes: volumesUser,
|
|
@@ -257,15 +225,6 @@ func TestMerge(t *testing.T) {
|
|
t.Error(err)
|
|
t.Error(err)
|
|
}
|
|
}
|
|
|
|
|
|
- if len(configUser.Dns) != 3 {
|
|
|
|
- t.Fatalf("Expected 3 dns, 1.1.1.1, 2.2.2.2 and 3.3.3.3, found %d", len(configUser.Dns))
|
|
|
|
- }
|
|
|
|
- for _, dns := range configUser.Dns {
|
|
|
|
- if dns != "1.1.1.1" && dns != "2.2.2.2" && dns != "3.3.3.3" {
|
|
|
|
- t.Fatalf("Expected 1.1.1.1 or 2.2.2.2 or 3.3.3.3, found %s", dns)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
if len(configUser.ExposedPorts) != 3 {
|
|
if len(configUser.ExposedPorts) != 3 {
|
|
t.Fatalf("Expected 3 ExposedPorts, 1111, 2222 and 3333, found %d", len(configUser.ExposedPorts))
|
|
t.Fatalf("Expected 3 ExposedPorts, 1111, 2222 and 3333, found %d", len(configUser.ExposedPorts))
|
|
}
|
|
}
|