(t *testing.T)
| 645 | } |
| 646 | |
| 647 | func TestRuntimeAPIVersionCachesNegotiation(t *testing.T) { |
| 648 | mockCtrl := gomock.NewController(t) |
| 649 | defer mockCtrl.Finish() |
| 650 | |
| 651 | apiClient := mocks.NewMockAPIClient(mockCtrl) |
| 652 | cli := mocks.NewMockCli(mockCtrl) |
| 653 | tested := &composeService{dockerCli: cli} |
| 654 | |
| 655 | cli.EXPECT().Client().Return(apiClient).AnyTimes() |
| 656 | |
| 657 | // Ping reports the server's max API version (1.44), but after negotiation |
| 658 | // the client may settle on a lower version (1.43) — e.g. when the client |
| 659 | // SDK caps at an older version. RuntimeAPIVersion must return the negotiated |
| 660 | // ClientVersion, not the server's raw APIVersion. |
| 661 | apiClient.EXPECT().Ping(gomock.Any(), client.PingOptions{NegotiateAPIVersion: true}).Return(client.PingResult{ |
| 662 | APIVersion: "1.44", |
| 663 | }, nil).Times(1) |
| 664 | apiClient.EXPECT().ClientVersion().Return("1.43").Times(1) |
| 665 | |
| 666 | version, err := tested.RuntimeAPIVersion(t.Context()) |
| 667 | assert.NilError(t, err) |
| 668 | assert.Equal(t, version, "1.43") |
| 669 | |
| 670 | version, err = tested.RuntimeAPIVersion(t.Context()) |
| 671 | assert.NilError(t, err) |
| 672 | assert.Equal(t, version, "1.43") |
| 673 | } |
| 674 | |
| 675 | func TestRuntimeAPIVersionRetriesOnTransientError(t *testing.T) { |
| 676 | mockCtrl := gomock.NewController(t) |
nothing calls this directly
no test coverage detected