1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Add unit test for swarm labels on containers

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2017-08-16 14:29:53 +02:00
parent 1fd7e4c28d
commit 6f8d17dad3
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -35,3 +35,48 @@ func TestIsolationConversion(t *testing.T) {
})
}
}
func TestContainerLabels(t *testing.T) {
c := &containerConfig{
task: &swarmapi.Task{
ID: "real-task.id",
Spec: swarmapi.TaskSpec{
Runtime: &swarmapi.TaskSpec_Container{
Container: &swarmapi.ContainerSpec{
Labels: map[string]string{
"com.docker.swarm.task": "user-specified-task",
"com.docker.swarm.task.id": "user-specified-task.id",
"com.docker.swarm.task.name": "user-specified-task.name",
"com.docker.swarm.node.id": "user-specified-node.id",
"com.docker.swarm.service.id": "user-specified-service.id",
"com.docker.swarm.service.name": "user-specified-service.name",
"this-is-a-user-label": "this is a user label's value",
},
},
},
},
ServiceID: "real-service.id",
Slot: 123,
NodeID: "real-node.id",
Annotations: swarmapi.Annotations{
Name: "real-service.name.123.real-task.id",
},
ServiceAnnotations: swarmapi.Annotations{
Name: "real-service.name",
},
},
}
expected := map[string]string{
"com.docker.swarm.task": "",
"com.docker.swarm.task.id": "real-task.id",
"com.docker.swarm.task.name": "real-service.name.123.real-task.id",
"com.docker.swarm.node.id": "real-node.id",
"com.docker.swarm.service.id": "real-service.id",
"com.docker.swarm.service.name": "real-service.name",
"this-is-a-user-label": "this is a user label's value",
}
labels := c.labels()
assert.DeepEqual(t, expected, labels)
}