浏览代码

add VolumesFrom to MergeConfig, and test

Victor Vieux 12 年之前
父节点
当前提交
1a226f0e28
共有 2 个文件被更改,包括 12 次插入4 次删除
  1. 3 0
      utils.go
  2. 9 4
      utils_test.go

+ 3 - 0
utils.go

@@ -132,6 +132,9 @@ func MergeConfig(userConf, imageConf *Config) {
 	if userConf.Entrypoint == nil || len(userConf.Entrypoint) == 0 {
 		userConf.Entrypoint = imageConf.Entrypoint
 	}
+	if userConf.VolumesFrom == "" {
+		userConf.VolumesFrom = imageConf.VolumesFrom
+	}
 	if userConf.Volumes == nil || len(userConf.Volumes) == 0 {
 		userConf.Volumes = imageConf.Volumes
 	} else {

+ 9 - 4
utils_test.go

@@ -191,10 +191,11 @@ func TestMergeConfig(t *testing.T) {
 	volumesImage["/test1"] = struct{}{}
 	volumesImage["/test2"] = struct{}{}
 	configImage := &Config{
-		Dns:       []string{"1.1.1.1", "2.2.2.2"},
-		PortSpecs: []string{"1111:1111", "2222:2222"},
-		Env:       []string{"VAR1=1", "VAR2=2"},
-		Volumes:   volumesImage,
+		Dns:         []string{"1.1.1.1", "2.2.2.2"},
+		PortSpecs:   []string{"1111:1111", "2222:2222"},
+		Env:         []string{"VAR1=1", "VAR2=2"},
+		VolumesFrom: "1111",
+		Volumes:     volumesImage,
 	}
 
 	volumesUser := make(map[string]struct{})
@@ -242,4 +243,8 @@ func TestMergeConfig(t *testing.T) {
 			t.Fatalf("Expected /test1 or /test2 or /test3, found %s", v)
 		}
 	}
+
+	if configUser.VolumesFrom != "1111" {
+		t.Fatalf("Expected VolumesFrom to be 1111, found %s", configUser.VolumesFrom)
+	}
 }