(t *testing.T)
| 29 | ) |
| 30 | |
| 31 | func TestLoadProject_Basic(t *testing.T) { |
| 32 | // Create a temporary compose file |
| 33 | tmpDir := t.TempDir() |
| 34 | composeFile := filepath.Join(tmpDir, "compose.yaml") |
| 35 | composeContent := ` |
| 36 | name: test-project |
| 37 | services: |
| 38 | web: |
| 39 | image: nginx:latest |
| 40 | ports: |
| 41 | - "8080:80" |
| 42 | db: |
| 43 | image: postgres:latest |
| 44 | environment: |
| 45 | POSTGRES_PASSWORD: secret |
| 46 | ` |
| 47 | err := os.WriteFile(composeFile, []byte(composeContent), 0o644) |
| 48 | assert.NilError(t, err) |
| 49 | |
| 50 | service, err := NewComposeService(nil) |
| 51 | assert.NilError(t, err) |
| 52 | |
| 53 | // Load the project |
| 54 | project, err := service.LoadProject(t.Context(), api.ProjectLoadOptions{ |
| 55 | ConfigPaths: []string{composeFile}, |
| 56 | }) |
| 57 | |
| 58 | // Assertions |
| 59 | assert.NilError(t, err) |
| 60 | assert.Equal(t, "test-project", project.Name) |
| 61 | assert.Assert(t, is.Len(project.Services, 2)) |
| 62 | assert.Check(t, is.Contains(project.Services, "web")) |
| 63 | assert.Check(t, is.Contains(project.Services, "db")) |
| 64 | |
| 65 | // Check labels were applied |
| 66 | webService := project.Services["web"] |
| 67 | assert.Equal(t, "test-project", webService.CustomLabels[api.ProjectLabel]) |
| 68 | assert.Equal(t, "web", webService.CustomLabels[api.ServiceLabel]) |
| 69 | } |
| 70 | |
| 71 | func TestLoadProject_WithEnvironmentResolution(t *testing.T) { |
| 72 | tmpDir := t.TempDir() |
nothing calls this directly
no test coverage detected