1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/daemon/images/images_test.go
Brian Goff 3beb2e4422 Move cpu variant checks into platform matcher
Wrap platforms.Only and fallback to our ignore mismatches due to  empty
CPU variants. This just cleans things up and makes the logic re-usable
in other places.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
(cherry picked from commit 50f39e7247)
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2021-02-18 20:12:07 +00:00

33 lines
755 B
Go

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