@@ -10,7 +10,6 @@ import (
1010 "github.com/docker/cli/internal/test"
1111 "github.com/docker/cli/internal/test/builders"
1212 "github.com/moby/moby/api/types/swarm"
13- "github.com/moby/moby/api/types/versions"
1413 "github.com/moby/moby/client"
1514 "gotest.tools/v3/assert"
1615 is "gotest.tools/v3/assert/cmp"
@@ -63,59 +62,12 @@ func TestServiceListServiceStatus(t *testing.T) {
6362 cluster : & cluster {}, // force an empty cluster
6463 expected : []listResponse {},
6564 },
66- {
67- // Services are running, but no active nodes were found. On API v1.40
68- // and below, this will cause looking up the "running" tasks to fail,
69- // as well as looking up "desired" tasks for global services.
70- doc : "API v1.40 no active nodes" ,
71- opts : clusterOpts {
72- apiVersion : "1.40" ,
73- activeNodes : 0 ,
74- runningTasks : 2 ,
75- desiredTasks : 4 ,
76- },
77- expected : []listResponse {
78- {ID : "replicated" , Replicas : "0/4" },
79- {ID : "global" , Replicas : "0/0" },
80- {ID : "none-id" , Replicas : "0/0" },
81- },
82- },
83- {
84- doc : "API v1.40 3 active nodes, 1 task running" ,
85- opts : clusterOpts {
86- apiVersion : "1.40" ,
87- activeNodes : 3 ,
88- runningTasks : 1 ,
89- desiredTasks : 2 ,
90- },
91- expected : []listResponse {
92- {ID : "replicated" , Replicas : "1/2" },
93- {ID : "global" , Replicas : "1/3" },
94- {ID : "none-id" , Replicas : "0/0" },
95- },
96- },
97- {
98- doc : "API v1.40 3 active nodes, all tasks running" ,
99- opts : clusterOpts {
100- apiVersion : "1.40" ,
101- activeNodes : 3 ,
102- runningTasks : 3 ,
103- desiredTasks : 3 ,
104- },
105- expected : []listResponse {
106- {ID : "replicated" , Replicas : "3/3" },
107- {ID : "global" , Replicas : "3/3" },
108- {ID : "none-id" , Replicas : "0/0" },
109- },
110- },
111-
11265 {
11366 // Services are running, but no active nodes were found. On API v1.41
11467 // and up, the ServiceStatus is sent by the daemon, so this should not
11568 // affect the results.
116- doc : "API v1.41 no active nodes" ,
69+ doc : "no active nodes" ,
11770 opts : clusterOpts {
118- apiVersion : "1.41" ,
11971 activeNodes : 0 ,
12072 runningTasks : 2 ,
12173 desiredTasks : 4 ,
@@ -127,9 +79,8 @@ func TestServiceListServiceStatus(t *testing.T) {
12779 },
12880 },
12981 {
130- doc : "API v1.41 3 active nodes, 1 task running" ,
82+ doc : "active nodes, 1 task running" ,
13183 opts : clusterOpts {
132- apiVersion : "1.41" ,
13384 activeNodes : 3 ,
13485 runningTasks : 1 ,
13586 desiredTasks : 2 ,
@@ -141,9 +92,8 @@ func TestServiceListServiceStatus(t *testing.T) {
14192 },
14293 },
14394 {
144- doc : "API v1.41 3 active nodes, all tasks running" ,
95+ doc : "active nodes, all tasks running" ,
14596 opts : clusterOpts {
146- apiVersion : "1.41" ,
14797 activeNodes : 3 ,
14898 runningTasks : 3 ,
14999 desiredTasks : 3 ,
@@ -174,7 +124,7 @@ func TestServiceListServiceStatus(t *testing.T) {
174124 }
175125 cli := test .NewFakeCli (& fakeClient {
176126 serviceListFunc : func (ctx context.Context , options client.ServiceListOptions ) ([]swarm.Service , error ) {
177- if ! options .Status || versions . LessThan ( tc . opts . apiVersion , "1.41" ) {
127+ if ! options .Status {
178128 // Don't return "ServiceStatus" if not requested, or on older API versions
179129 for i := range tc .cluster .services {
180130 tc .cluster .services [i ].ServiceStatus = nil
@@ -214,7 +164,6 @@ func TestServiceListServiceStatus(t *testing.T) {
214164}
215165
216166type clusterOpts struct {
217- apiVersion string
218167 activeNodes uint64
219168 desiredTasks uint64
220169 runningTasks uint64
0 commit comments