MCPcopy
hub / github.com/moby/moby / TestEncodePlatforms

Function TestEncodePlatforms

client/utils_test.go:14–60  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestEncodePlatforms(t *testing.T) {
15 tests := []struct {
16 doc string
17 platforms []ocispec.Platform
18 expected []string
19 }{
20 {
21 doc: "single platform",
22 platforms: []ocispec.Platform{
23 {Architecture: "arm64", OS: "windows", Variant: "v8", OSVersion: "99.99.99"},
24 },
25 expected: []string{
26 `{"architecture":"arm64","os":"windows","os.version":"99.99.99","variant":"v8"}`,
27 },
28 },
29 {
30 doc: "multiple platforms",
31 platforms: []ocispec.Platform{
32 {Architecture: "arm64", OS: "linux", Variant: "v8"},
33 {Architecture: "arm64", OS: "windows", Variant: "v8", OSVersion: "99.99.99"},
34 },
35 expected: []string{
36 `{"architecture":"arm64","os":"linux","variant":"v8"}`,
37 `{"architecture":"arm64","os":"windows","os.version":"99.99.99","variant":"v8"}`,
38 },
39 },
40 {
41 doc: "multiple platforms with duplicates",
42 platforms: []ocispec.Platform{
43 {Architecture: "arm64", OS: "linux", Variant: "v8"},
44 {Architecture: "arm64", OS: "windows", Variant: "v8", OSVersion: "99.99.99"},
45 {Architecture: "arm64", OS: "linux", Variant: "v8"},
46 },
47 expected: []string{
48 `{"architecture":"arm64","os":"linux","variant":"v8"}`,
49 `{"architecture":"arm64","os":"windows","os.version":"99.99.99","variant":"v8"}`,
50 },
51 },
52 }
53 for _, tc := range tests {
54 t.Run(tc.doc, func(t *testing.T) {
55 out, err := encodePlatforms(tc.platforms...)
56 assert.NilError(t, err)
57 assert.Check(t, is.DeepEqual(out, tc.expected))
58 })
59 }
60}
61
62func TestNewCancelReadCloserRace(t *testing.T) {
63 for range 1000 {

Callers

nothing calls this directly

Calls 3

encodePlatformsFunction · 0.85
CheckMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…