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

Function TestLoadProject_ServiceSelection

pkg/compose/loader_test.go:121–150  ·  pkg/compose/loader_test.go::TestLoadProject_ServiceSelection
(t *testing.T)

Source from the content-addressed store, hash-verified

119}
120
121func TestLoadProject_ServiceSelection(t *testing.T) {
122 tmpDir := t.TempDir()
123 composeFile := filepath.Join(tmpDir, "compose.yaml")
124 composeContent := `
125services:
126 web:
127 image: nginx:latest
128 db:
129 image: postgres:latest
130 cache:
131 image: redis:latest
132`
133 err := os.WriteFile(composeFile, []byte(composeContent), 0o644)
134 assert.NilError(t, err)
135
136 service, err := NewComposeService(nil)
137 assert.NilError(t, err)
138
139 // Load only specific services
140 project, err := service.LoadProject(t.Context(), api.ProjectLoadOptions{
141 ConfigPaths: []string{composeFile},
142 Services: []string{"web", "db"},
143 })
144
145 assert.NilError(t, err)
146 assert.Check(t, is.Len(project.Services, 2))
147 assert.Check(t, is.Contains(project.Services, "web"))
148 assert.Check(t, is.Contains(project.Services, "db"))
149 assert.Check(t, !is.Contains(project.Services, "cache")().Success())
150}
151
152func TestLoadProject_WithProfiles(t *testing.T) {
153 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