ronantakizawa/codereview-bench huggingface dataset:
Repository: moby/moby
File: integration/container/stats_test.go (Go)

Code before:

	t.Run("one-shot", func(t *testing.T) {
		resp, err := apiClient.ContainerStats(ctx, cID, client.ContainerStatsOptions{
			Stream:                false,
			IncludePreviousSample: false,
		})
		assert.NilError(t, err)
		defer func() { _ = resp.Body.Close() }()

		var v containertypes.StatsResponse
		err = json.NewDecoder(resp.Body).Decode(&v)
		assert.NilError(t, err)
		assert.Check(t, is.Equal(int64(v.MemoryStats.Limit), info.MemTotal))
		assert.Check(t, reflect.DeepEqual(v.PreCPUStats, containertypes.CPUStats{}))
		err = json.NewDecoder(resp.Body).Decode(&v)
		assert.Assert(t, is.ErrorIs(err, io.EOF))
	})
}

func TestStatsContainerNotFound(t *testing.T) {
	skip.If(t, testEnv.DaemonInfo.OSType == "windows")

	ctx := setupTest(t)
	apiClient := testEnv.APIClient()

	_, err := apiClient.ContainerStats(ctx, "no-such-container", client.ContainerStatsOptions{
		Stream: true,
	})
	assert.ErrorType(t, err, cerrdefs.IsNotFound)
	assert.ErrorContains(t, err, "no-such-container")

	_, err = apiClient.ContainerStats(ctx, "no-such-container", client.ContainerStatsOptions{
		Stream:                false,
		IncludePreviousSample: true,
	})
	assert.ErrorType(t, err, cerrdefs.IsNotFound)
	assert.ErrorContains(t, err, "no-such-container")
}


Review comment (bug):
As there are two tests doing the same thing (just with different options) - it'd be best to use a test array, see [TestAttach](https://github.com/moby/moby/blob/42eb0aa97390fd1a9af1924d48575a31b51a6b01/integration/container/attach_test.go#L20) for an example. Then each test gets its own result, the second still runs if the first fails, and we can add more if we think of them.

```
	tests := []struct {
		name    string
		options client.ContainerStatsOptions
	}{
        ...
    }
```

Code after:

	t.Run("one-shot", func(t *testing.T) {
		resp, err := apiClient.ContainerStats(ctx, cID, client.ContainerStatsOptions{
			Stream:                false,
			IncludePreviousSample: false,
		})
		assert.NilError(t, err)
		defer func() { _ = resp.Body.Close() }()

		var v containertypes.StatsResponse
		err = json.NewDecoder(resp.Body).Decode(&v)
		assert.NilError(t, err)
		assert.Check(t, is.Equal(int64(v.MemoryStats.Limit), info.MemTotal))
		assert.Check(t, reflect.DeepEqual(v.PreCPUStats, containertypes.CPUStats{}))
		err = json.NewDecoder(resp.Body).Decode(&v)
		assert.Assert(t, is.ErrorIs(err, io.EOF))
	})
}

func TestStatsContainerNotFound(t *testing.T) {
	ctx := setupTest(t)
	apiClient := testEnv.APIClient()

	tests := []struct {
		name    string
		options client.ContainerStatsOptions
	}{
		{
			name: "with stream",
			options: client.ContainerStatsOptions{
				Stream: true,
			},
		},
		{
			name: "without stream",
			options: client.ContainerStatsOptions{
				Stream:                false,
				IncludePreviousSample: true,
			},
		},
	}

	for _, tc := range tests {
		t.Run(tc.name, func(t *testing.T) {
			_, err := apiClient.ContainerStats(ctx, "no-such-container", tc.options)
			assert.ErrorType(t, err, cerrdefs.IsNotFound)
			assert.ErrorContains(t, err, "no-such-container")
		})
	}
}
Repository: moby/moby
File: daemon/image_store_choice.go (Go)

Code before:
				driverName = "windows"
			}
		default:
			log.G(ctx).Infof("Using non-default snapshotter %s", driverName)

		}
	}
	return driverName
}

func determineImageStoreChoice(cfgStore *config.Config) (imageStoreChoice, error) {
	out := imageStoreChoiceContainerd
	if runtime.GOOS == "windows" {
		out = imageStoreChoiceGraphdriver
	}

	driverName := os.Getenv("DOCKER_DRIVER")
	if driverName == "" {
		driverName = cfgStore.GraphDriver
	}

	if enabled, ok := cfgStore.Features["containerd-snapshotter"]; ok {
		if enabled {
			if out == imageStoreChoiceContainerd {
				log.G(context.TODO()).Warn(`"containerd-snapshotter" is now the default and no longer needed to be set`)
			}
			out = imageStoreChoiceContainerdExplicit
		} else {
			out = imageStoreChoiceGraphdriverExplicit
		}
	}

	if os.Getenv("TEST_INTEGRATION_USE_GRAPHDRIVER") != "" {
		out = imageStoreChoiceGraphdriverExplicit
	}

	if driverName != "" {
		if !out.IsExplicit() {
			switch driverName {
			case "vfs", "overlay2":
				out = imageStoreChoiceGraphdriverExplicit
			case "btrfs":
				// The btrfs driver is not heavily used in containerd and has no
				// advantage over overlayfs anymore since overlay works fine.
				// If btrfs is explicitly chosen, the user most likely means graphdrivers.
				out = imageStoreChoiceGraphdriverExplicit
			}
		}
		if out.IsGraphDriver() {
			if graphdriver.IsRegistered(driverName) {
				return imageStoreChoiceGraphdriverExplicit, nil

Review comment (suggestion):
To eliminate this, as the tests always provide all three opts anyway, could define a package-level var containing the daemon's opts and use that in its call? (Instead of creating the zero-valued struct in the call, then initialising it here.)

Code after:
				driverName = "windows"
			}
		default:
			log.G(ctx).Infof("Using non-default snapshotter %s", driverName)

		}
	}
	return driverName
}

type determineImageStoreChoiceOptions struct {
	hasPriorDriver          func(root string) bool
	isRegisteredGraphdriver func(driverName string) bool
	runtimeOS               string
}

func determineImageStoreChoice(cfgStore *config.Config, opts determineImageStoreChoiceOptions) (imageStoreChoice, error) {
	if opts.hasPriorDriver == nil {
		opts.hasPriorDriver = graphdriver.HasPriorDriver
	}
	if opts.isRegisteredGraphdriver == nil {
		opts.isRegisteredGraphdriver = graphdriver.IsRegistered
	}
	if opts.runtimeOS == "" {
		opts.runtimeOS = runtime.GOOS
	}

	out := imageStoreChoiceContainerd
	if opts.runtimeOS == "windows" {
		out = imageStoreChoiceGraphdriver
	}

	driverName := os.Getenv("DOCKER_DRIVER")
	if driverName == "" {
		driverName = cfgStore.GraphDriver
	}

	if enabled, ok := cfgStore.Features["containerd-snapshotter"]; ok {
		if enabled {
			if out == imageStoreChoiceContainerd {
				log.G(context.TODO()).Warn(`"containerd-snapshotter" is now the default and no longer needed to be set`)
			}
			out = imageStoreChoiceContainerdExplicit
		} else {
			out = imageStoreChoiceGraphdriverExplicit
		}
	}

	if os.Getenv("TEST_INTEGRATION_USE_GRAPHDRIVER") != "" {
		out = imageStoreChoiceGraphdriverExplicit
	}
Repository: moby/moby
File: integration/networking/bridge_linux_test.go (Go)

Code before:
					}

					// Legacy links env var found, and expected. No need to check further.
					found = true
					break
				}
			}

			if !found && tc.expectEnvVars {
				t.Fatal("no legacy links env vars found")
			}
		})
	}
}

// TestDNSNamesForNonSwarmScopedNetworks checks that container names can be resolved for non-swarm-scoped networks once
// a node has joined a Swarm cluster.
//
// Regression test for https://github.com/moby/moby/issues/51491.
func TestDNSNamesForNonSwarmScopedNetworks(t *testing.T) {
	ctx := setupTest(t)

	d := daemon.New(t)
	d.StartAndSwarmInit(ctx, t)
	defer d.Stop(t)
	defer d.SwarmLeave(ctx, t, true)

	c := d.NewClientT(t)
	defer c.Close()

	const bridgeName = "dnsnames-with-swarm"
	network.CreateNoError(ctx, t, c, bridgeName)
	defer network.RemoveNoError(ctx, t, c, bridgeName)

	res := container.RunAttach(ctx, t, c,
		container.WithName("test"),
		container.WithCmd("nslookup", "test"),
		container.WithNetworkMode(bridgeName),
		container.WithAutoRemove)
	assert.Equal(t, res.ExitCode, 0, "exit code: %d, expected 0; stdout:\n%s", res.ExitCode, res.Stdout)
}


Review comment (suggestion):
Nit/question - does this do anything after the `Stop`? (Probably no need to `SwarmLeave` at all, as it's a throw-away daemon?)

Code after:
					}

					// Legacy links env var found, and expected. No need to check further.
					found = true
					break
				}
			}

			if !found && tc.expectEnvVars {
				t.Fatal("no legacy links env vars found")
			}
		})
	}
}

// TestDNSNamesForNonSwarmScopedNetworks checks that container names can be resolved for non-swarm-scoped networks once
// a node has joined a Swarm cluster.
//
// Regression test for https://github.com/moby/moby/issues/51491.
func TestDNSNamesForNonSwarmScopedNetworks(t *testing.T) {
	ctx := setupTest(t)

	d := daemon.New(t)
	d.StartAndSwarmInit(ctx, t)
	defer d.Stop(t)

	c := d.NewClientT(t)
	defer c.Close()

	const bridgeName = "dnsnames-with-swarm"
	network.CreateNoError(ctx, t, c, bridgeName)
	defer network.RemoveNoError(ctx, t, c, bridgeName)

	res := container.RunAttach(ctx, t, c,
		container.WithName("test"),
		container.WithCmd("nslookup", "-type=a", "test."),
		container.WithNetworkMode(bridgeName),
		container.WithAutoRemove)
	assert.Equal(t, res.ExitCode, 0, "exit code: %d, expected 0; stdout:\n%s", res.ExitCode, res.Stdout)
}
Repository: moby/moby
File: integration/image/remove_test.go (Go)

Code before:

    const name = "test-api-images-delete"

    buildCtx := fakecontext.New(t, t.TempDir(),
        fakecontext.WithDockerfile(`FROM busybox
ENV FOO bar`))
    defer buildCtx.Close()

    imgID := build.Do(ctx, t, apiClient, buildCtx)

    // Cleanup always runs
    defer func() {
        _, _ = apiClient.ImageRemove(ctx, imgID, client.ImageRemoveOptions{Force: true})
    }()

    _, err := apiClient.ImageTag(ctx, client.ImageTagOptions{Source: imgID, Target: name})
    assert.NilError(t, err)

    _, err = apiClient.ImageTag(ctx, client.ImageTagOptions{Source: imgID, Target: "test:tag1"})
    assert.NilError(t, err)

    _, err = apiClient.ImageRemove(ctx, imgID, client.ImageRemoveOptions{})
    assert.Check(t, is.ErrorContains(err, "unable to delete"))

    _, err = apiClient.ImageRemove(ctx, "test:noexist", client.ImageRemoveOptions{})
    assert.Check(t, is.ErrorContains(err, "No such image"))

    _, err = apiClient.ImageRemove(ctx, "test:tag1", client.ImageRemoveOptions{})
    assert.NilError(t, err)
}


Review comment (suggestion):
Not critical (can be a follow up) but perhaps we should update this to check the error type returned instead of string matching; we could still check if the error contains the image name (to double check the cause is indeed because of the image), but checking for the kind of error may be more relevant than the error message; similar to https://github.com/moby/moby/blob/27cefe6c43b74d429bbfa01dfd106ca8837e8bfe/integration/container/stats_test.go#L91

Code after:
	apiClient := testEnv.APIClient()

	const name = "test-api-images-delete"

	buildCtx := fakecontext.New(t, t.TempDir(),
		fakecontext.WithDockerfile(`FROM busybox
ENV FOO=bar`))
	defer buildCtx.Close()

	imgID := build.Do(ctx, t, apiClient, buildCtx)

	// Cleanup always runs
	defer func() {
		_, _ = apiClient.ImageRemove(ctx, imgID, client.ImageRemoveOptions{Force: true})
	}()

	_, err := apiClient.ImageTag(ctx, client.ImageTagOptions{Source: imgID, Target: name})
	assert.NilError(t, err)

	_, err = apiClient.ImageTag(ctx, client.ImageTagOptions{Source: imgID, Target: "test:tag1"})
	assert.NilError(t, err)

	_, err = apiClient.ImageRemove(ctx, imgID, client.ImageRemoveOptions{})
	assert.Check(t, is.ErrorType(err, cerrdefs.IsConflict))
	assert.Check(t, is.ErrorContains(err, "unable to delete "+stringid.TruncateID(imgID)))

	_, err = apiClient.ImageRemove(ctx, "test:noexist", client.ImageRemoveOptions{})
	assert.Check(t, is.ErrorType(err, cerrdefs.IsNotFound))
	assert.Check(t, is.ErrorContains(err, "No such image: test:noexist"))

	_, err = apiClient.ImageRemove(ctx, "test:tag1", client.ImageRemoveOptions{})
	assert.NilError(t, err)
}
Repository: moby/moby
File: integration/image/remove_test.go (Go)

Code before:

	const name = "test-api-images-delete"

	buildCtx := fakecontext.New(t, t.TempDir(),
		fakecontext.WithDockerfile(`FROM busybox
ENV FOO=bar`))
	defer buildCtx.Close()

	imgID := build.Do(ctx, t, apiClient, buildCtx)

	// Cleanup always runs
	defer func() {
		_, _ = apiClient.ImageRemove(ctx, imgID, client.ImageRemoveOptions{Force: true})
	}()

	_, err := apiClient.ImageTag(ctx, client.ImageTagOptions{Source: imgID, Target: name})
	assert.NilError(t, err)

	_, err = apiClient.ImageTag(ctx, client.ImageTagOptions{Source: imgID, Target: "test:tag1"})
	assert.NilError(t, err)

	_, err = apiClient.ImageRemove(ctx, imgID, client.ImageRemoveOptions{})
	assert.Check(t, is.ErrorContains(err, "unable to delete"))

	_, err = apiClient.ImageRemove(ctx, "test:noexist", client.ImageRemoveOptions{})
	assert.ErrorType(t, err, cerrdefs.IsNotFound)

	_, err = apiClient.ImageRemove(ctx, "test:tag1", client.ImageRemoveOptions{})
	assert.NilError(t, err)
}


Review comment (bug):
Thanks @2003Aditya - to implement the suggestion "to check the error type returned instead of string matching; we could still check if the error contains the image name (to double check the cause is indeed because of the image)" ... would need an error-type and a string check for both errors.

So, also using `assert.Check` so later checks still run if one fails, it'd be ...

```suggestion
	_, err = apiClient.ImageRemove(ctx, imgID, client.ImageRemoveOptions{})
	assert.Check(t, is.ErrorType(err, cerrdefs.IsConflict))
	assert.Check(t, is.ErrorContains(err, "unable to delete "+stringid.TruncateID(imgID)))

	_, err = apiClient.ImageRemove(ctx, "test:noexist", client.ImageRemoveOptions{})
	assert.Check(t, is.ErrorType(err, cerrdefs.IsNotFound))
	assert.Check(t, is.ErrorContains(err, "No such image: test:noexist"))
```

Code after:
	apiClient := testEnv.APIClient()

	const name = "test-api-images-delete"

	buildCtx := fakecontext.New(t, t.TempDir(),
		fakecontext.WithDockerfile(`FROM busybox
ENV FOO=bar`))
	defer buildCtx.Close()

	imgID := build.Do(ctx, t, apiClient, buildCtx)

	// Cleanup always runs
	defer func() {
		_, _ = apiClient.ImageRemove(ctx, imgID, client.ImageRemoveOptions{Force: true})
	}()

	_, err := apiClient.ImageTag(ctx, client.ImageTagOptions{Source: imgID, Target: name})
	assert.NilError(t, err)

	_, err = apiClient.ImageTag(ctx, client.ImageTagOptions{Source: imgID, Target: "test:tag1"})
	assert.NilError(t, err)

	_, err = apiClient.ImageRemove(ctx, imgID, client.ImageRemoveOptions{})
	assert.Check(t, is.ErrorType(err, cerrdefs.IsConflict))
	assert.Check(t, is.ErrorContains(err, "unable to delete "+stringid.TruncateID(imgID)))

	_, err = apiClient.ImageRemove(ctx, "test:noexist", client.ImageRemoveOptions{})
	assert.Check(t, is.ErrorType(err, cerrdefs.IsNotFound))
	assert.Check(t, is.ErrorContains(err, "No such image: test:noexist"))

	_, err = apiClient.ImageRemove(ctx, "test:tag1", client.ImageRemoveOptions{})
	assert.NilError(t, err)
}
Repository: moby/moby
File: client/client.go (Go)

Code before:
/*
Package client is a Go client for the Docker Engine API.

For more information about the Engine API, see the documentation:
https://docs.docker.com/reference/api/engine/

# Usage

You use the library by constructing a client object using [New]
and calling methods on it. The client can be configured from environment
variables by passing the [FromEnv] option. Other options cen be configured
manually by passing any of the available [Opt] options.

For example, to list running containers (the equivalent of "docker ps"):

	package main

	import (
		"context"
		"fmt"
		"log"

		"github.com/moby/moby/client"
	)

	func main() {
		// Create a new client that handles common environment variables
		// for configuration (DOCKER_HOST, DOCKER_API_VERSION), and does
		// API-version negotiation to allow downgrading the API version
		// when connecting with an older daemon version.
		apiClient, err := client.New(client.FromEnv)
		if err != nil {
			log.Fatal(err)
		}

		// List all containers (both stopped and running).

Review comment (suggestion):
```suggestion
variables by passing the [FromEnv] option. Other options can be configured
```

Sorry! 🙈 

Code after:
/*
Package client is a Go client for the Docker Engine API.

For more information about the Engine API, see the documentation:
https://docs.docker.com/reference/api/engine/

# Usage

You use the library by constructing a client object using [New]
and calling methods on it. The client can be configured from environment
variables by passing the [FromEnv] option. Other options can be configured
manually by passing any of the available [Opt] options.

For example, to list running containers (the equivalent of "docker ps"):

	package main

	import (
		"context"
		"fmt"
		"log"

		"github.com/moby/moby/client"
	)

	func main() {
		// Create a new client that handles common environment variables
		// for configuration (DOCKER_HOST, DOCKER_API_VERSION), and does
		// API-version negotiation to allow downgrading the API version
		// when connecting with an older daemon version.
		apiClient, err := client.New(client.FromEnv)
		if err != nil {
			log.Fatal(err)
		}

		// List all containers (both stopped and running).
Repository: moby/moby
File: integration/image/size_test.go (Go)

Code before:
package image

import (
	"testing"

	"github.com/moby/moby/client"
	"gotest.tools/v3/assert"
)

func TestAPIImagesSizeCompatibility(t *testing.T) {
	ctx := setupTest(t)
	apiClient := testEnv.APIClient()

	imageList, err := apiClient.ImageList(ctx, client.ImageListOptions{})
	assert.NilError(t, err)
	assert.Assert(t, len(imageList.Items) != 0)
	for _, img := range imageList.Items {
		assert.Assert(t, img.Size != int64(-1))
	}

	oldClient, err := client.New(client.FromEnv, client.WithAPIVersion("v1.24"))
	assert.NilError(t, err)
	defer oldClient.Close()

	v124Images, err := oldClient.ImageList(ctx, client.ImageListOptions{})
	assert.NilError(t, err)
	assert.Assert(t, len(v124Images.Items) != 0)
	for _, img := range v124Images.Items {
		assert.Assert(t, img.Size != int64(-1))
	}

}


Review comment (suggestion):
```suggestion
// Test case for 30027: image size reported as -1 in v1.12 client against v1.13 daemon.
func TestAPIImagesSizeCompatibility(t *testing.T) {
```

Code after:
package image

import (
	"testing"

	"github.com/moby/moby/client"
	"gotest.tools/v3/assert"
)

// Test case for 30027: image size reported as -1
// in v1.12 client against v1.13 daemon.
func TestImagesSizeCompatibility(t *testing.T) {
	ctx := setupTest(t)

	testCases := []struct {
		name       string
		apiVersion string
	}{
		{name: "LatestAPIVersion", apiVersion: ""},
		{name: "MinimumAPIVersion", apiVersion: client.MinAPIVersion},
	}

	for _, tc := range testCases {
		t.Run(tc.name, func(t *testing.T) {
			cli, err := client.New(
				client.FromEnv,
				client.WithAPIVersion(tc.apiVersion),
			)
			assert.NilError(t, err)
			defer cli.Close()

			images, err := cli.ImageList(ctx, client.ImageListOptions{})
			assert.NilError(t, err)
			assert.Assert(t, len(images.Items) > 0)
Repository: moby/moby
File: integration/image/size_test.go (Go)

Code before:
package image

import (
	"testing"

	"github.com/moby/moby/client"
	"gotest.tools/v3/assert"
)

func TestAPIImagesSizeCompatibility(t *testing.T) {
	ctx := setupTest(t)
	apiClient := testEnv.APIClient()

	imageList, err := apiClient.ImageList(ctx, client.ImageListOptions{})
	assert.NilError(t, err)
	assert.Assert(t, len(imageList.Items) != 0)
	for _, img := range imageList.Items {
		assert.Assert(t, img.Size != int64(-1))
	}

	oldClient, err := client.New(client.FromEnv, client.WithAPIVersion("v1.24"))
	assert.NilError(t, err)
	defer oldClient.Close()

	v124Images, err := oldClient.ImageList(ctx, client.ImageListOptions{})
	assert.NilError(t, err)
	assert.Assert(t, len(v124Images.Items) != 0)
	for _, img := range v124Images.Items {
		assert.Assert(t, img.Size != int64(-1))
	}

}


Review comment (suggestion):
```suggestion
	oldClient, err := client.New(client.FromEnv, client.WithAPIVersion(client.MinAPIVersion))
```

Code after:
package image

import (
	"testing"

	"github.com/moby/moby/client"
	"gotest.tools/v3/assert"
)

// Test case for 30027: image size reported as -1
// in v1.12 client against v1.13 daemon.
func TestImagesSizeCompatibility(t *testing.T) {
	ctx := setupTest(t)

	testCases := []struct {
		name       string
		apiVersion string
	}{
		{name: "LatestAPIVersion", apiVersion: ""},
		{name: "MinimumAPIVersion", apiVersion: client.MinAPIVersion},
	}

	for _, tc := range testCases {
		t.Run(tc.name, func(t *testing.T) {
			cli, err := client.New(
				client.FromEnv,
				client.WithAPIVersion(tc.apiVersion),
			)
			assert.NilError(t, err)
			defer cli.Close()

			images, err := cli.ImageList(ctx, client.ImageListOptions{})
			assert.NilError(t, err)
			assert.Assert(t, len(images.Items) > 0)

			for _, img := range images.Items {
				assert.Check(t, img.Size >= 0)
			}
		})
	}
}
Repository: moby/moby
File: integration/image/size_test.go (Go)

Code before:
package image

import (
	"testing"

	"github.com/moby/moby/client"
	"gotest.tools/v3/assert"
)

func TestAPIImagesSizeCompatibility(t *testing.T) {
	ctx := setupTest(t)
	apiClient := testEnv.APIClient()

	imageList, err := apiClient.ImageList(ctx, client.ImageListOptions{})
	assert.NilError(t, err)
	assert.Assert(t, len(imageList.Items) != 0)
	for _, img := range imageList.Items {
		assert.Assert(t, img.Size != int64(-1))
	}

	oldClient, err := client.New(client.FromEnv, client.WithAPIVersion("v1.24"))
	assert.NilError(t, err)
	defer oldClient.Close()

	v124Images, err := oldClient.ImageList(ctx, client.ImageListOptions{})
	assert.NilError(t, err)
	assert.Assert(t, len(v124Images.Items) != 0)
	for _, img := range v124Images.Items {
		assert.Assert(t, img.Size != int64(-1))
	}

}


Review comment (bug):
I think it'd be worth using a `testcases` array, so the two tests run as subtests - `MinAPIVersion` and `MaxAPIVersion`. (At the moment, if the first test fails the second won't run.)

Code after:
package image

import (
	"testing"

	"github.com/moby/moby/client"
	"gotest.tools/v3/assert"
)

// Test case for 30027: image size reported as -1
// in v1.12 client against v1.13 daemon.
func TestImagesSizeCompatibility(t *testing.T) {
	ctx := setupTest(t)

	testCases := []struct {
		name       string
		apiVersion string
	}{
		{name: "LatestAPIVersion", apiVersion: ""},
		{name: "MinimumAPIVersion", apiVersion: client.MinAPIVersion},
	}

	for _, tc := range testCases {
		t.Run(tc.name, func(t *testing.T) {
			cli, err := client.New(
				client.FromEnv,
				client.WithAPIVersion(tc.apiVersion),
			)
			assert.NilError(t, err)
			defer cli.Close()

			images, err := cli.ImageList(ctx, client.ImageListOptions{})
			assert.NilError(t, err)
			assert.Assert(t, len(images.Items) > 0)

			for _, img := range images.Items {
				assert.Check(t, img.Size >= 0)
			}
		})
	}
}