images_test.go 765 B

123456789101112131415161718192021222324252627282930313233
  1. package images
  2. import (
  3. "testing"
  4. ocispec "github.com/opencontainers/image-spec/specs-go/v1"
  5. "gotest.tools/v3/assert"
  6. )
  7. func TestOnlyPlatformWithFallback(t *testing.T) {
  8. p := ocispec.Platform{
  9. OS: "linux",
  10. Architecture: "arm",
  11. Variant: "v8",
  12. }
  13. // Check no variant
  14. assert.Assert(t, OnlyPlatformWithFallback(p).Match(ocispec.Platform{
  15. OS: p.OS,
  16. Architecture: p.Architecture,
  17. }))
  18. // check with variant
  19. assert.Assert(t, OnlyPlatformWithFallback(p).Match(ocispec.Platform{
  20. OS: p.OS,
  21. Architecture: p.Architecture,
  22. Variant: p.Variant,
  23. }))
  24. // Make sure non-matches are false.
  25. assert.Assert(t, !OnlyPlatformWithFallback(p).Match(ocispec.Platform{
  26. OS: p.OS,
  27. Architecture: "amd64",
  28. }))
  29. }