(t *testing.T)
| 499 | } |
| 500 | |
| 501 | func TestCreateMobyContainerLegacyAPI(t *testing.T) { |
| 502 | mockCtrl := gomock.NewController(t) |
| 503 | defer mockCtrl.Finish() |
| 504 | apiClient := mocks.NewMockAPIClient(mockCtrl) |
| 505 | cli := mocks.NewMockCli(mockCtrl) |
| 506 | tested, err := NewComposeService(cli) |
| 507 | assert.NilError(t, err) |
| 508 | cli.EXPECT().Client().Return(apiClient).AnyTimes() |
| 509 | cli.EXPECT().ConfigFile().Return(&configfile.ConfigFile{}).AnyTimes() |
| 510 | apiClient.EXPECT().DaemonHost().Return("").AnyTimes() |
| 511 | apiClient.EXPECT().ImageInspect(anyCancellableContext(), gomock.Any()). |
| 512 | Return(client.ImageInspectResult{}, nil).AnyTimes() |
| 513 | |
| 514 | apiClient.EXPECT().Ping(gomock.Any(), client.PingOptions{NegotiateAPIVersion: true}). |
| 515 | Return(client.PingResult{APIVersion: "1.43"}, nil).AnyTimes() |
| 516 | apiClient.EXPECT().ClientVersion().Return("1.43").AnyTimes() |
| 517 | |
| 518 | service := types.ServiceConfig{ |
| 519 | Name: "test", |
| 520 | Networks: map[string]*types.ServiceNetworkConfig{ |
| 521 | "a": {Priority: 10}, |
| 522 | "b": {Priority: 100}, |
| 523 | }, |
| 524 | } |
| 525 | project := types.Project{ |
| 526 | Name: "bork", |
| 527 | Services: types.Services{ |
| 528 | "test": service, |
| 529 | }, |
| 530 | Networks: types.Networks{ |
| 531 | "a": types.NetworkConfig{Name: "a-moby-name"}, |
| 532 | "b": types.NetworkConfig{Name: "b-moby-name"}, |
| 533 | }, |
| 534 | } |
| 535 | |
| 536 | var gotCreate client.ContainerCreateOptions |
| 537 | apiClient.EXPECT().ContainerCreate(gomock.Any(), gomock.Any()). |
| 538 | DoAndReturn(func(_ context.Context, opts client.ContainerCreateOptions) (client.ContainerCreateResult, error) { |
| 539 | gotCreate = opts |
| 540 | return client.ContainerCreateResult{ID: "an-id"}, nil |
| 541 | }) |
| 542 | |
| 543 | // For API < 1.44, the secondary network "a" should be connected via NetworkConnect. |
| 544 | var gotConnect client.NetworkConnectOptions |
| 545 | connectCall := apiClient.EXPECT(). |
| 546 | NetworkConnect(gomock.Any(), gomock.Eq("a-moby-name"), gomock.Any()). |
| 547 | DoAndReturn(func(_ context.Context, _ string, opts client.NetworkConnectOptions) (client.NetworkConnectResult, error) { |
| 548 | gotConnect = opts |
| 549 | return client.NetworkConnectResult{}, nil |
| 550 | }) |
| 551 | |
| 552 | apiClient.EXPECT().ContainerInspect(gomock.Any(), gomock.Eq("an-id"), gomock.Any()). |
| 553 | Times(1).After(connectCall).Return(client.ContainerInspectResult{ |
| 554 | Container: container.InspectResponse{ |
| 555 | ID: "an-id", |
| 556 | Name: "a-name", |
| 557 | Config: &container.Config{}, |
| 558 | NetworkSettings: &container.NetworkSettings{ |
nothing calls this directly
no test coverage detected