Enable some image-pull tests on Windows

Now that they are using a multi-arch image, they should work on Windows
like they work elsewhere.

This also means non-AMD64 platforms do this test with their native
platform version, not the linux/amd64 platform version.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
This commit is contained in:
Paul "TBBle" Hampson 2021-03-13 12:23:53 +11:00
parent b375f90128
commit 5cfc4a80d4

View File

@ -31,10 +31,6 @@ import (
) )
func TestImageIsUnpacked(t *testing.T) { func TestImageIsUnpacked(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip()
}
const imageName = "k8s.gcr.io/pause:3.4.1" const imageName = "k8s.gcr.io/pause:3.4.1"
ctx, cancel := testContext(t) ctx, cancel := testContext(t)
defer cancel() defer cancel()
@ -53,7 +49,7 @@ func TestImageIsUnpacked(t *testing.T) {
} }
// By default pull does not unpack an image // By default pull does not unpack an image
image, err := client.Pull(ctx, imageName, WithPlatform("linux/amd64")) image, err := client.Pull(ctx, imageName, WithPlatformMatcher(platforms.Default()))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -82,9 +78,6 @@ func TestImageIsUnpacked(t *testing.T) {
} }
func TestImagePullWithDistSourceLabel(t *testing.T) { func TestImagePullWithDistSourceLabel(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip()
}
var ( var (
source = "k8s.gcr.io" source = "k8s.gcr.io"
repoName = "pause" repoName = "pause"
@ -140,7 +133,7 @@ func TestImagePullWithDistSourceLabel(t *testing.T) {
} }
func TestImageUsage(t *testing.T) { func TestImageUsage(t *testing.T) {
if testing.Short() || runtime.GOOS == "windows" { if testing.Short() {
t.Skip() t.Skip()
} }
@ -160,13 +153,10 @@ func TestImageUsage(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
testPlatform := platforms.Only(ocispec.Platform{ pMatcher := platforms.Default()
OS: "linux",
Architecture: "amd64",
})
// Pull single platform, do not unpack // Pull single platform, do not unpack
image, err := client.Pull(ctx, imageName, WithPlatformMatcher(testPlatform)) image, err := client.Pull(ctx, imageName, WithPlatformMatcher(pMatcher))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -187,7 +177,7 @@ func TestImageUsage(t *testing.T) {
defer client.ImageService().Delete(ctx, imageName, images.SynchronousDelete()) defer client.ImageService().Delete(ctx, imageName, images.SynchronousDelete())
// Fetch single platforms, but all manifests pulled // Fetch single platforms, but all manifests pulled
if _, err := client.Fetch(ctx, imageName, WithPlatformMatcher(testPlatform), WithAllMetadata()); err != nil { if _, err := client.Fetch(ctx, imageName, WithPlatformMatcher(pMatcher), WithAllMetadata()); err != nil {
t.Fatal(err) t.Fatal(err)
} }