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

Function TestLoadProject_WithProfiles

pkg/compose/loader_test.go:152–190  ·  pkg/compose/loader_test.go::TestLoadProject_WithProfiles
(t *testing.T)

Source from the content-addressed store, hash-verified

150}
151
152func TestLoadProject_WithProfiles(t *testing.T) {
153 tmpDir := t.TempDir()
154 composeFile := filepath.Join(tmpDir, "compose.yaml")
155 composeContent := `
156services:
157 web:
158 image: nginx:latest
159 debug:
160 image: busybox:latest
161 profiles: ["debug"]
162`
163 err := os.WriteFile(composeFile, []byte(composeContent), 0o644)
164 assert.NilError(t, err)
165
166 service, err := NewComposeService(nil)
167 assert.NilError(t, err)
168
169 // Without debug profile
170 t.Run("WithoutProfile", func(t *testing.T) {
171 project, err := service.LoadProject(t.Context(), api.ProjectLoadOptions{
172 ConfigPaths: []string{composeFile},
173 })
174 assert.NilError(t, err)
175 assert.Check(t, is.Len(project.Services, 1))
176 assert.Check(t, is.Contains(project.Services, "web"))
177 })
178
179 // With debug profile
180 t.Run("WithProfile", func(t *testing.T) {
181 project, err := service.LoadProject(t.Context(), api.ProjectLoadOptions{
182 ConfigPaths: []string{composeFile},
183 Profiles: []string{"debug"},
184 })
185 assert.NilError(t, err)
186 assert.Check(t, is.Len(project.Services, 2))
187 assert.Check(t, is.Contains(project.Services, "web"))
188 assert.Check(t, is.Contains(project.Services, "debug"))
189 })
190}
191
192func TestLoadProject_WithLoadListeners(t *testing.T) {
193 tmpDir := t.TempDir()

Callers

nothing calls this directly

Calls 5

NewComposeServiceFunction · 0.85
TempDirMethod · 0.80
WriteFileMethod · 0.80
LenMethod · 0.80
LoadProjectMethod · 0.65

Tested by

no test coverage detected