2021-02-17 20:41:12 +00:00
|
|
|
package images
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-05-08 09:57:52 +00:00
|
|
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
2021-02-17 20:41:12 +00:00
|
|
|
"gotest.tools/v3/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestOnlyPlatformWithFallback(t *testing.T) {
|
2023-05-08 09:57:52 +00:00
|
|
|
p := ocispec.Platform{
|
2021-02-17 20:41:12 +00:00
|
|
|
OS: "linux",
|
|
|
|
Architecture: "arm",
|
|
|
|
Variant: "v8",
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check no variant
|
2023-05-08 09:57:52 +00:00
|
|
|
assert.Assert(t, OnlyPlatformWithFallback(p).Match(ocispec.Platform{
|
2021-02-17 20:41:12 +00:00
|
|
|
OS: p.OS,
|
|
|
|
Architecture: p.Architecture,
|
|
|
|
}))
|
|
|
|
// check with variant
|
2023-05-08 09:57:52 +00:00
|
|
|
assert.Assert(t, OnlyPlatformWithFallback(p).Match(ocispec.Platform{
|
2021-02-17 20:41:12 +00:00
|
|
|
OS: p.OS,
|
|
|
|
Architecture: p.Architecture,
|
|
|
|
Variant: p.Variant,
|
|
|
|
}))
|
|
|
|
// Make sure non-matches are false.
|
2023-05-08 09:57:52 +00:00
|
|
|
assert.Assert(t, !OnlyPlatformWithFallback(p).Match(ocispec.Platform{
|
2021-02-17 20:41:12 +00:00
|
|
|
OS: p.OS,
|
|
|
|
Architecture: "amd64",
|
|
|
|
}))
|
|
|
|
}
|