Skip to content

Commit

Permalink
Add API test for empty services list
Browse files Browse the repository at this point in the history
Signed-off-by: Ralf Sippl <ralf.sippl@gmail.com>
  • Loading branch information
rsippl committed Jul 12, 2016
1 parent c8e4e95 commit 65e7213
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions integration-cli/daemon_swarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,16 @@ func (d *SwarmDaemon) listNodes(c *check.C) []swarm.Node {
return nodes
}

func (d *SwarmDaemon) listServices(c *check.C) []swarm.Service {
status, out, err := d.SockRequest("GET", "/services", nil)
c.Assert(err, checker.IsNil)
c.Assert(status, checker.Equals, http.StatusOK, check.Commentf("output: %q", string(out)))

services := []swarm.Service{}
c.Assert(json.Unmarshal(out, &services), checker.IsNil)
return services
}

func (d *SwarmDaemon) updateSwarm(c *check.C, f ...specConstructor) {
var sw swarm.Swarm
status, out, err := d.SockRequest("GET", "/swarm", nil)
Expand Down
9 changes: 9 additions & 0 deletions integration-cli/docker_api_swarm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,15 @@ func (s *DockerSwarmSuite) TestApiSwarmPromoteDemote(c *check.C) {
waitAndAssert(c, defaultReconciliationTimeout, d2.checkControlAvailable, checker.True)
}

func (s *DockerSwarmSuite) TestApiSwarmServicesEmptyList(c *check.C) {
testRequires(c, Network)
d := s.AddDaemon(c, true, true)

services := d.listServices(c)
c.Assert(services, checker.NotNil)
c.Assert(len(services), checker.Equals, 0, check.Commentf("services: %#v", services))
}

func (s *DockerSwarmSuite) TestApiSwarmServicesCreate(c *check.C) {
testRequires(c, Network)
d := s.AddDaemon(c, true, true)
Expand Down

0 comments on commit 65e7213

Please sign in to comment.