c8d/save: Add tests#48722
Conversation
| t.Run("export without specific platform", func(t *testing.T) { | ||
| // TODO(vvoland): https://github.com/docker/cli/issues/5476 | ||
| t.Skip() | ||
| err = imgSvc.ExportImage(ctx, []string{img.Name}, nil, io.Discard) | ||
| assert.NilError(t, err) | ||
| }) |
There was a problem hiding this comment.
This tests the issue reported in: docker/cli#5476
2853400 to
6144d22
Compare
6144d22 to
5bfd9dc
Compare
Test saving a shallow/partial image Signed-off-by: Paweł Gronowski <[email protected]>
5bfd9dc to
db68a01
Compare
| is "gotest.tools/v3/assert/cmp" | ||
| ) | ||
|
|
||
| func TestImageMultiplatformSaveShallowWithNative(t *testing.T) { |
There was a problem hiding this comment.
Wondering if we could somehow combine these two tests in a test-table. I went looking what the differences are, and this is the diff if I copy the other test's content here;
diff --git a/daemon/containerd/image_save_test.go b/daemon/containerd/image_save_test.go
index 13a9c86565..9fb565fc7b 100644
--- a/daemon/containerd/image_save_test.go
+++ b/daemon/containerd/image_save_test.go
@@ -35,9 +35,9 @@ func TestImageMultiplatformSaveShallowWithNative(t *testing.T) {
// Mock the native platform.
imgSvc.defaultPlatformOverride = platforms.Only(native)
- idx, _, err := specialimage.PartialMultiPlatform(contentDir, "partial-with-native:latest", specialimage.PartialOpts{
- Stored: []ocispec.Platform{native},
- Missing: []ocispec.Platform{arm64},
+ idx, _, err := specialimage.PartialMultiPlatform(contentDir, "partial-without-native:latest", specialimage.PartialOpts{
+ Stored: []ocispec.Platform{arm64},
+ Missing: []ocispec.Platform{native},
})
assert.NilError(t, err)
@@ -45,16 +45,17 @@ func TestImageMultiplatformSaveShallowWithNative(t *testing.T) {
assert.NilError(t, err)
t.Run("export without specific platform", func(t *testing.T) {
+ t.Skip("TODO(vvoland): https://github.com/docker/cli/issues/5476")
err = imgSvc.ExportImage(ctx, []string{img.Name}, nil, io.Discard)
assert.NilError(t, err)
})
t.Run("export native", func(t *testing.T) {
err = imgSvc.ExportImage(ctx, []string{img.Name}, &native, io.Discard)
- assert.NilError(t, err)
+ assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
})
- t.Run("export missing", func(t *testing.T) {
+ t.Run("export arm64", func(t *testing.T) {
err = imgSvc.ExportImage(ctx, []string{img.Name}, &arm64, io.Discard)
- assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
+ assert.NilError(t, err)
})
}There was a problem hiding this comment.
We could, but IMO that makes the test less clear. Separation also helps a bit with the TODO case which only fails in one of these tests.
There was a problem hiding this comment.
Separation also helps a bit with the TODO case which only fails in one of these tests.
Yeah, that's fair. I was considering the amount of boiler plating, and possibly having to keep those in sync, but it's not a blocker.
| is "gotest.tools/v3/assert/cmp" | ||
| ) | ||
|
|
||
| func TestImageMultiplatformSaveShallowWithNative(t *testing.T) { |
There was a problem hiding this comment.
Separation also helps a bit with the TODO case which only fails in one of these tests.
Yeah, that's fair. I was considering the amount of boiler plating, and possibly having to keep those in sync, but it's not a blocker.
| native := platforms.Platform{ | ||
| OS: "linux", | ||
| Architecture: "amd64", | ||
| } |
There was a problem hiding this comment.
Considering if we should have a really fictive platform for native (e.g. cpm/z80); I know we're mocking things, but to reduce risk of a test falling through an matching actual native platforms (which can differ where you're running).
(also not a blocker, mostly thinking out loud here)q
Test saving a shallow/partial image.
- How to verify it
TestImageMultiplatformSaveShallowWithNativeandTestImageMultiplatformSaveShallowWithoutNative- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)