github.com/Heebron/moby@v0.0.0-20221111184709-6eab4f55faf7/daemon/images/images_test.go (about)

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