summaryrefslogtreecommitdiff
path: root/daemon/images/images_test.go
blob: 24e380d3fdc103085293d35de9e5c0cc17e9c71e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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",
	}))
}