(t *testing.T)
| 68 | } |
| 69 | |
| 70 | func 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 | |
| 105 | func TestApplyPlatforms_UnsupportedPlatform(t *testing.T) { |
| 106 | makeProject := func() *types.Project { |
nothing calls this directly
no test coverage detected