Merge pull request #420 from Random-Liu/add-unit-test

Add simple unit test.
This commit is contained in:
Mike Brown 2017-11-17 08:29:57 -06:00 committed by GitHub
commit 921be46c49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -126,3 +126,19 @@ func TestGetCgroupsPath(t *testing.T) {
assert.Equal(t, test.expected, got)
}
}
func TestBuildLabels(t *testing.T) {
configLabels := map[string]string{
"a": "b",
"c": "d",
}
newLabels := buildLabels(configLabels, containerKindSandbox)
assert.Len(t, newLabels, 3)
assert.Equal(t, "b", newLabels["a"])
assert.Equal(t, "d", newLabels["c"])
assert.Equal(t, containerKindSandbox, newLabels[containerKindLabel])
newLabels["a"] = "e"
assert.Empty(t, configLabels[containerKindLabel], "should not add new labels into original label")
assert.Equal(t, "b", configLabels["a"], "change in new labels should not affect original label")
}