MCPcopy
hub / github.com/docker/compose / TestRuntimeAPIVersionCachesNegotiation

Function TestRuntimeAPIVersionCachesNegotiation

pkg/compose/convergence_test.go:647–673  ·  pkg/compose/convergence_test.go::TestRuntimeAPIVersionCachesNegotiation
(t *testing.T)

Source from the content-addressed store, hash-verified

645}
646
647func 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
675func TestRuntimeAPIVersionRetriesOnTransientError(t *testing.T) {
676 mockCtrl := gomock.NewController(t)

Callers

nothing calls this directly

Calls 8

EXPECTMethod · 0.95
EXPECTMethod · 0.95
RuntimeAPIVersionMethod · 0.95
NewMockAPIClientFunction · 0.92
NewMockCliFunction · 0.92
ClientMethod · 0.45
PingMethod · 0.45
ClientVersionMethod · 0.45

Tested by

no test coverage detected