moby/daemon/images/images_test.go
Jeyanthinath Muthuram 307b09e7eb
fixing consistent aliases for OCI spec imports
Signed-off-by: Jeyanthinath Muthuram <jeyanthinath10@gmail.com>
2023-05-08 15:27:52 +05:30

33 lines
765 B
Go

package images
import (
"testing"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"gotest.tools/v3/assert"
)
func TestOnlyPlatformWithFallback(t *testing.T) {
p := ocispec.Platform{
OS: "linux",
Architecture: "arm",
Variant: "v8",
}
// Check no variant
assert.Assert(t, OnlyPlatformWithFallback(p).Match(ocispec.Platform{
OS: p.OS,
Architecture: p.Architecture,
}))
// check with variant
assert.Assert(t, OnlyPlatformWithFallback(p).Match(ocispec.Platform{
OS: p.OS,
Architecture: p.Architecture,
Variant: p.Variant,
}))
// Make sure non-matches are false.
assert.Assert(t, !OnlyPlatformWithFallback(p).Match(ocispec.Platform{
OS: p.OS,
Architecture: "amd64",
}))
}