github.com/docker/Engine@v17.12.1-ce-rc2+incompatible/integration-cli/docker_cli_config_inspect_test.go (about) 1 // +build !windows 2 3 package main 4 5 import ( 6 "encoding/json" 7 8 "github.com/docker/docker/api/types/swarm" 9 "github.com/docker/docker/integration-cli/checker" 10 "github.com/go-check/check" 11 ) 12 13 func (s *DockerSwarmSuite) TestConfigInspect(c *check.C) { 14 d := s.AddDaemon(c, true, true) 15 16 testName := "test_config" 17 id := d.CreateConfig(c, swarm.ConfigSpec{ 18 Annotations: swarm.Annotations{ 19 Name: testName, 20 }, 21 Data: []byte("TESTINGDATA"), 22 }) 23 c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("configs: %s", id)) 24 25 config := d.GetConfig(c, id) 26 c.Assert(config.Spec.Name, checker.Equals, testName) 27 28 out, err := d.Cmd("config", "inspect", testName) 29 c.Assert(err, checker.IsNil, check.Commentf(out)) 30 31 var configs []swarm.Config 32 c.Assert(json.Unmarshal([]byte(out), &configs), checker.IsNil) 33 c.Assert(configs, checker.HasLen, 1) 34 } 35 36 func (s *DockerSwarmSuite) TestConfigInspectMultiple(c *check.C) { 37 d := s.AddDaemon(c, true, true) 38 39 testNames := []string{ 40 "test0", 41 "test1", 42 } 43 for _, n := range testNames { 44 id := d.CreateConfig(c, swarm.ConfigSpec{ 45 Annotations: swarm.Annotations{ 46 Name: n, 47 }, 48 Data: []byte("TESTINGDATA"), 49 }) 50 c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("configs: %s", id)) 51 52 config := d.GetConfig(c, id) 53 c.Assert(config.Spec.Name, checker.Equals, n) 54 55 } 56 57 args := []string{ 58 "config", 59 "inspect", 60 } 61 args = append(args, testNames...) 62 out, err := d.Cmd(args...) 63 c.Assert(err, checker.IsNil, check.Commentf(out)) 64 65 var configs []swarm.Config 66 c.Assert(json.Unmarshal([]byte(out), &configs), checker.IsNil) 67 c.Assert(configs, checker.HasLen, 2) 68 }