Skip to content

Commit

Permalink
Merge pull request #4873 from vvoland/test-daemon-apiversion
Browse files Browse the repository at this point in the history
testenv: Add DaemonAPIVersion helper
  • Loading branch information
thaJeztah authored Feb 13, 2024
2 parents d1b8893 + 9831fea commit a253318
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/test/environment/testenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,14 @@ func SkipIfNotPlatform(t *testing.T, platform string) {
daemonPlatform := strings.TrimSpace(result.Stdout())
skip.If(t, daemonPlatform != platform, "running against a non %s daemon", platform)
}

// DaemonAPIVersion returns the negotiated daemon API version.
func DaemonAPIVersion(t *testing.T) string {
t.Helper()
// Use Client.APIVersion instead of Server.APIVersion.
// The latter is the maximum version that the server supports
// while the Client.APIVersion contains the negotiated version.
result := icmd.RunCmd(icmd.Command("docker", "version", "--format", "{{.Client.APIVersion}}"))
result.Assert(t, icmd.Expected{Err: icmd.None})
return strings.TrimSpace(result.Stdout())
}

0 comments on commit a253318

Please sign in to comment.