(t *testing.T)
| 69 | } |
| 70 | |
| 71 | func TestLoadProject_WithEnvironmentResolution(t *testing.T) { |
| 72 | tmpDir := t.TempDir() |
| 73 | composeFile := filepath.Join(tmpDir, "compose.yaml") |
| 74 | composeContent := ` |
| 75 | services: |
| 76 | app: |
| 77 | image: myapp:latest |
| 78 | environment: |
| 79 | - TEST_VAR=${TEST_VAR} |
| 80 | - LITERAL_VAR=literal_value |
| 81 | ` |
| 82 | err := os.WriteFile(composeFile, []byte(composeContent), 0o644) |
| 83 | assert.NilError(t, err) |
| 84 | |
| 85 | // Set environment variable |
| 86 | t.Setenv("TEST_VAR", "resolved_value") |
| 87 | |
| 88 | service, err := NewComposeService(nil) |
| 89 | assert.NilError(t, err) |
| 90 | |
| 91 | // Test with environment resolution (default) |
| 92 | t.Run("WithResolution", func(t *testing.T) { |
| 93 | project, err := service.LoadProject(t.Context(), api.ProjectLoadOptions{ |
| 94 | ConfigPaths: []string{composeFile}, |
| 95 | }) |
| 96 | assert.NilError(t, err) |
| 97 | |
| 98 | appService := project.Services["app"] |
| 99 | // Environment should be resolved |
| 100 | assert.Assert(t, appService.Environment["TEST_VAR"] != nil) |
| 101 | assert.Equal(t, "resolved_value", *appService.Environment["TEST_VAR"]) |
| 102 | assert.Assert(t, appService.Environment["LITERAL_VAR"] != nil) |
| 103 | assert.Equal(t, "literal_value", *appService.Environment["LITERAL_VAR"]) |
| 104 | }) |
| 105 | |
| 106 | // Test without environment resolution |
| 107 | t.Run("WithoutResolution", func(t *testing.T) { |
| 108 | project, err := service.LoadProject(t.Context(), api.ProjectLoadOptions{ |
| 109 | ConfigPaths: []string{composeFile}, |
| 110 | ProjectOptionsFns: []cli.ProjectOptionsFn{cli.WithoutEnvironmentResolution}, |
| 111 | }) |
| 112 | assert.NilError(t, err) |
| 113 | |
| 114 | appService := project.Services["app"] |
| 115 | // Environment should NOT be resolved, keeping raw values |
| 116 | // Note: This depends on compose-go behavior, which may still have some resolution |
| 117 | assert.Assert(t, appService.Environment != nil) |
| 118 | }) |
| 119 | } |
| 120 | |
| 121 | func TestLoadProject_ServiceSelection(t *testing.T) { |
| 122 | tmpDir := t.TempDir() |
nothing calls this directly
no test coverage detected