MCPcopy
hub / github.com/docker/compose / TestApplyPlatforms_InferFromRuntime

Function TestApplyPlatforms_InferFromRuntime

cmd/compose/options_test.go:36–68  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

34)
35
36func TestApplyPlatforms_InferFromRuntime(t *testing.T) {
37 makeProject := func() *types.Project {
38 return &types.Project{
39 Services: types.Services{
40 "test": {
41 Name: "test",
42 Image: "foo",
43 Build: &types.BuildConfig{
44 Context: ".",
45 Platforms: []string{
46 "linux/amd64",
47 "linux/arm64",
48 "alice/32",
49 },
50 },
51 Platform: "alice/32",
52 },
53 },
54 }
55 }
56
57 t.Run("SinglePlatform", func(t *testing.T) {
58 project := makeProject()
59 assert.NilError(t, applyPlatforms(project, true))
60 assert.DeepEqual(t, types.StringList{"alice/32"}, project.Services["test"].Build.Platforms)
61 })
62
63 t.Run("MultiPlatform", func(t *testing.T) {
64 project := makeProject()
65 assert.NilError(t, applyPlatforms(project, false))
66 assert.DeepEqual(t, types.StringList{"linux/amd64", "linux/arm64", "alice/32"}, project.Services["test"].Build.Platforms)
67 })
68}
69
70func TestApplyPlatforms_DockerDefaultPlatform(t *testing.T) {
71 makeProject := func() *types.Project {

Callers

nothing calls this directly

Calls 1

applyPlatformsFunction · 0.85

Tested by

no test coverage detected