浏览代码

Add CompareConfig test

Victor Vieux 12 年之前
父节点
当前提交
48a892bee5
共有 1 个文件被更改,包括 24 次插入0 次删除
  1. 24 0
      utils_test.go

+ 24 - 0
utils_test.go

@@ -129,6 +129,30 @@ func runContainer(r *Runtime, args []string, t *testing.T) (output string, err e
 	return
 }
 
+func TestCompareConfig(t *testing.T) {
+	config1 := Config{
+		Dns:       []string{"1.1.1.1", "2.2.2.2"},
+		PortSpecs: []string{"1111:1111", "2222:2222"},
+		Env:       []string{"VAR1=1", "VAR2=2"},
+	}
+	config2 := Config{
+		Dns:       []string{"0.0.0.0", "2.2.2.2"},
+		PortSpecs: []string{"1111:1111", "2222:2222"},
+		Env:       []string{"VAR1=1", "VAR2=2"},
+	}
+	config3 := Config{
+		Dns:       []string{"1.1.1.1", "2.2.2.2"},
+		PortSpecs: []string{"0000:0000", "2222:2222"},
+		Env:       []string{"VAR1=1", "VAR2=2"},
+	}
+	if CompareConfig(&config1, &config2) {
+		t.Fatalf("CompareConfig should return false, Dns are different")
+	}
+	if CompareConfig(&config1, &config3) {
+		t.Fatalf("CompareConfig should return false, PortSpecs are different")
+	}
+}
+
 func TestMergeConfig(t *testing.T) {
 	volumesImage := make(map[string]struct{})
 	volumesImage["/test1"] = struct{}{}