Browse code

add integration tests for secret create with labels

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

Evan Hazlett authored on 2016/11/04 06:28:56
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,48 @@
0
+// +build !windows
1
+
2
+package main
3
+
4
+import (
5
+	"github.com/docker/docker/api/types/swarm"
6
+	"github.com/docker/docker/pkg/integration/checker"
7
+	"github.com/go-check/check"
8
+)
9
+
10
+func (s *DockerSwarmSuite) TestSecretCreate(c *check.C) {
11
+	d := s.AddDaemon(c, true, true)
12
+
13
+	testName := "test_secret"
14
+	id := d.createSecret(c, swarm.SecretSpec{
15
+		swarm.Annotations{
16
+			Name: testName,
17
+		},
18
+		[]byte("TESTINGDATA"),
19
+	})
20
+	c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
21
+
22
+	secret := d.getSecret(c, id)
23
+	c.Assert(secret.Spec.Name, checker.Equals, testName)
24
+}
25
+
26
+func (s *DockerSwarmSuite) TestSecretCreateWithLabels(c *check.C) {
27
+	d := s.AddDaemon(c, true, true)
28
+
29
+	testName := "test_secret"
30
+	id := d.createSecret(c, swarm.SecretSpec{
31
+		swarm.Annotations{
32
+			Name: testName,
33
+			Labels: map[string]string{
34
+				"key1": "value1",
35
+				"key2": "value2",
36
+			},
37
+		},
38
+		[]byte("TESTINGDATA"),
39
+	})
40
+	c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
41
+
42
+	secret := d.getSecret(c, id)
43
+	c.Assert(secret.Spec.Name, checker.Equals, testName)
44
+	c.Assert(len(secret.Spec.Labels), checker.Equals, 2)
45
+	c.Assert(secret.Spec.Labels["key1"], checker.Equals, "value1")
46
+	c.Assert(secret.Spec.Labels["key2"], checker.Equals, "value2")
47
+}