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

Function TestApplyPlatforms_DockerDefaultPlatform

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

Source from the content-addressed store, hash-verified

68}
69
70func TestApplyPlatforms_DockerDefaultPlatform(t *testing.T) {
71 makeProject := func() *types.Project {
72 return &types.Project{
73 Environment: map[string]string{
74 "DOCKER_DEFAULT_PLATFORM": "linux/amd64",
75 },
76 Services: types.Services{
77 "test": {
78 Name: "test",
79 Image: "foo",
80 Build: &types.BuildConfig{
81 Context: ".",
82 Platforms: []string{
83 "linux/amd64",
84 "linux/arm64",
85 },
86 },
87 },
88 },
89 }
90 }
91
92 t.Run("SinglePlatform", func(t *testing.T) {
93 project := makeProject()
94 assert.NilError(t, applyPlatforms(project, true))
95 assert.DeepEqual(t, types.StringList{"linux/amd64"}, project.Services["test"].Build.Platforms)
96 })
97
98 t.Run("MultiPlatform", func(t *testing.T) {
99 project := makeProject()
100 assert.NilError(t, applyPlatforms(project, false))
101 assert.DeepEqual(t, types.StringList{"linux/amd64", "linux/arm64"}, project.Services["test"].Build.Platforms)
102 })
103}
104
105func TestApplyPlatforms_UnsupportedPlatform(t *testing.T) {
106 makeProject := func() *types.Project {

Callers

nothing calls this directly

Calls 1

applyPlatformsFunction · 0.85

Tested by

no test coverage detected