(t *testing.T)
| 216 | } |
| 217 | |
| 218 | func TestToServiceNetwork(t *testing.T) { |
| 219 | nws := []network.Inspect{ |
| 220 | { |
| 221 | Network: network.Network{ |
| 222 | Name: "aaa-network", |
| 223 | ID: "id555", |
| 224 | }, |
| 225 | }, |
| 226 | { |
| 227 | Network: network.Network{ |
| 228 | Name: "mmm-network", |
| 229 | ID: "id999", |
| 230 | }, |
| 231 | }, |
| 232 | { |
| 233 | Network: network.Network{ |
| 234 | Name: "zzz-network", |
| 235 | ID: "id111", |
| 236 | }, |
| 237 | }, |
| 238 | } |
| 239 | |
| 240 | apiClient := &fakeClient{ |
| 241 | networkInspectFunc: func(ctx context.Context, networkID string, options client.NetworkInspectOptions) (client.NetworkInspectResult, error) { |
| 242 | for _, nw := range nws { |
| 243 | if nw.ID == networkID || nw.Name == networkID { |
| 244 | return client.NetworkInspectResult{Network: nw}, nil |
| 245 | } |
| 246 | } |
| 247 | return client.NetworkInspectResult{}, fmt.Errorf("network not found: %s", networkID) |
| 248 | }, |
| 249 | } |
| 250 | |
| 251 | nwo := opts.NetworkOpt{} |
| 252 | assert.NilError(t, nwo.Set("zzz-network")) |
| 253 | assert.NilError(t, nwo.Set("mmm-network")) |
| 254 | assert.NilError(t, nwo.Set("aaa-network")) |
| 255 | |
| 256 | o := newServiceOptions() |
| 257 | o.mode = "replicated" |
| 258 | o.networks = nwo |
| 259 | |
| 260 | ctx := context.Background() |
| 261 | flags := newCreateCommand(nil).Flags() |
| 262 | service, err := o.ToService(ctx, apiClient, flags) |
| 263 | assert.NilError(t, err) |
| 264 | assert.Check(t, is.DeepEqual([]swarm.NetworkAttachmentConfig{{Target: "id111"}, {Target: "id555"}, {Target: "id999"}}, service.TaskTemplate.Networks)) |
| 265 | } |
| 266 | |
| 267 | func TestToServicePidsLimit(t *testing.T) { |
| 268 | flags := newCreateCommand(nil).Flags() |
nothing calls this directly
no test coverage detected
searching dependent graphs…