Browse Source

integration-cli: TestAPIClientVersionOldNotSupported: use daemon API version

Use the minimum API version as advertised by the test-daemon, instead of the
hard-coded API version from code.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 1 năm trước cách đây
mục cha
commit
7f68e3107e
1 tập tin đã thay đổi với 5 bổ sung9 xóa
  1. 5 9
      integration-cli/docker_api_test.go

+ 5 - 9
integration-cli/docker_api_test.go

@@ -10,7 +10,6 @@ import (
 	"strings"
 	"testing"
 
-	"github.com/docker/docker/api"
 	"github.com/docker/docker/api/types/versions"
 	"github.com/docker/docker/runconfig"
 	"github.com/docker/docker/testutil"
@@ -52,21 +51,18 @@ func (s *DockerAPISuite) TestAPIClientVersionOldNotSupported(c *testing.T) {
 	if testEnv.DaemonInfo.OSType != runtime.GOOS {
 		c.Skip("Daemon platform doesn't match test platform")
 	}
-	if api.MinVersion == api.DefaultVersion {
-		c.Skip("API MinVersion==DefaultVersion")
-	}
-	v := strings.Split(api.MinVersion, ".")
-	vMinInt, err := strconv.Atoi(v[1])
+
+	major, minor, _ := strings.Cut(testEnv.DaemonVersion.MinAPIVersion, ".")
+	vMinInt, err := strconv.Atoi(minor)
 	assert.NilError(c, err)
 	vMinInt--
-	v[1] = strconv.Itoa(vMinInt)
-	version := strings.Join(v, ".")
+	version := fmt.Sprintf("%s.%d", major, vMinInt)
 
 	resp, body, err := request.Get(testutil.GetContext(c), "/v"+version+"/version")
 	assert.NilError(c, err)
 	defer body.Close()
 	assert.Equal(c, resp.StatusCode, http.StatusBadRequest)
-	expected := fmt.Sprintf("client version %s is too old. Minimum supported API version is %s, please upgrade your client to a newer version", version, api.MinVersion)
+	expected := fmt.Sprintf("client version %s is too old. Minimum supported API version is %s, please upgrade your client to a newer version", version, testEnv.DaemonVersion.MinAPIVersion)
 	content, err := io.ReadAll(body)
 	assert.NilError(c, err)
 	assert.Equal(c, strings.TrimSpace(string(content)), expected)