Browse code

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 authored on 2023/12/05 06:58:47
Showing 1 changed files
... ...
@@ -10,7 +10,6 @@ import (
10 10
 	"strings"
11 11
 	"testing"
12 12
 
13
-	"github.com/docker/docker/api"
14 13
 	"github.com/docker/docker/api/types/versions"
15 14
 	"github.com/docker/docker/runconfig"
16 15
 	"github.com/docker/docker/testutil"
... ...
@@ -52,21 +51,18 @@ func (s *DockerAPISuite) TestAPIClientVersionOldNotSupported(c *testing.T) {
52 52
 	if testEnv.DaemonInfo.OSType != runtime.GOOS {
53 53
 		c.Skip("Daemon platform doesn't match test platform")
54 54
 	}
55
-	if api.MinVersion == api.DefaultVersion {
56
-		c.Skip("API MinVersion==DefaultVersion")
57
-	}
58
-	v := strings.Split(api.MinVersion, ".")
59
-	vMinInt, err := strconv.Atoi(v[1])
55
+
56
+	major, minor, _ := strings.Cut(testEnv.DaemonVersion.MinAPIVersion, ".")
57
+	vMinInt, err := strconv.Atoi(minor)
60 58
 	assert.NilError(c, err)
61 59
 	vMinInt--
62
-	v[1] = strconv.Itoa(vMinInt)
63
-	version := strings.Join(v, ".")
60
+	version := fmt.Sprintf("%s.%d", major, vMinInt)
64 61
 
65 62
 	resp, body, err := request.Get(testutil.GetContext(c), "/v"+version+"/version")
66 63
 	assert.NilError(c, err)
67 64
 	defer body.Close()
68 65
 	assert.Equal(c, resp.StatusCode, http.StatusBadRequest)
69
-	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)
66
+	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)
70 67
 	content, err := io.ReadAll(body)
71 68
 	assert.NilError(c, err)
72 69
 	assert.Equal(c, strings.TrimSpace(string(content)), expected)