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

Function TestLoadProject_Compatibility

pkg/compose/loader_test.go:260–287  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

258}
259
260func TestLoadProject_Compatibility(t *testing.T) {
261 tmpDir := t.TempDir()
262 composeFile := filepath.Join(tmpDir, "compose.yaml")
263 composeContent := `
264services:
265 web:
266 image: nginx:latest
267`
268 err := os.WriteFile(composeFile, []byte(composeContent), 0o644)
269 assert.NilError(t, err)
270
271 service, err := NewComposeService(nil)
272 assert.NilError(t, err)
273
274 // With compatibility mode
275 project, err := service.LoadProject(t.Context(), api.ProjectLoadOptions{
276 ConfigPaths: []string{composeFile},
277 Compatibility: true,
278 })
279
280 assert.NilError(t, err)
281 assert.Assert(t, project != nil)
282 // In compatibility mode, separator should be "_"
283 assert.Equal(t, "_", api.Separator)
284
285 // Reset separator
286 api.Separator = "-"
287}
288
289func TestLoadProject_InvalidComposeFile(t *testing.T) {
290 tmpDir := t.TempDir()

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected