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

Function loadProjectForTest

pkg/compose/publish_test.go:272–291  ·  view source on GitHub ↗

--- collectEnvCheckFindings: pure detection logic ---

(t *testing.T, files map[string]string)

Source from the content-addressed store, hash-verified

270// --- collectEnvCheckFindings: pure detection logic ---
271
272func loadProjectForTest(t *testing.T, files map[string]string) *types.Project {
273 t.Helper()
274 dir := t.TempDir()
275 for name, content := range files {
276 path := filepath.Join(dir, name)
277 assert.NilError(t, os.MkdirAll(filepath.Dir(path), 0o755))
278 assert.NilError(t, os.WriteFile(path, []byte(content), 0o600))
279 }
280 composePath := filepath.Join(dir, "compose.yaml")
281 project, err := loader.LoadWithContext(t.Context(), types.ConfigDetails{
282 WorkingDir: dir,
283 Environment: types.Mapping{},
284 ConfigFiles: []types.ConfigFile{{Filename: composePath}},
285 }, func(options *loader.Options) {
286 options.SetProjectName("test", true)
287 })
288 assert.NilError(t, err)
289 project.ComposeFiles = []string{composePath}
290 return project
291}
292
293func Test_collectEnvCheckFindings(t *testing.T) {
294 tests := []struct {

Calls 4

TempDirMethod · 0.80
MkdirAllMethod · 0.80
WriteFileMethod · 0.80
DirMethod · 0.45

Tested by

no test coverage detected