|
1 | | -# CLAUDE.md |
| 1 | +# Contributing to pulumitest |
2 | 2 |
|
3 | | -This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 3 | +This guide provides detailed information about the pulumitest library's architecture, testing patterns, and development practices. |
4 | 4 |
|
5 | 5 | ## Build Commands |
6 | 6 | - Run all tests in pulumitest module: `go test -v ./...` |
@@ -80,73 +80,8 @@ The library supports multiple ways to configure providers for testing: |
80 | 80 | - Sets `plugins.providers` in Pulumi.yaml for providers that don't support attachment |
81 | 81 | - Provider is started by Pulumi engine, not attached |
82 | 82 |
|
83 | | -### Testing Patterns |
84 | | - |
85 | | -**Default Behavior** |
86 | | -- Programs copied to temp directory (OS-specific or `PULUMITEST_TEMP_DIR`) |
87 | | -- Dependencies installed automatically unless `SkipInstall()` used |
88 | | -- Stack named "test" created automatically unless `SkipStackCreate()` used |
89 | | -- Local backend in temp directory unless `UseAmbientBackend()` used |
90 | | -- Stacks automatically destroyed on test completion |
91 | | -- Temp directories retained on failure for debugging (configurable via env vars) |
92 | | - |
93 | | -**gRPC Logging** (`grpcLog.go`, `grpcLog_test.go`) |
94 | | -- Enabled by default, written to `grpc.json` in working directory |
95 | | -- Disable with `opttest.DisableGrpcLog()` |
96 | | -- Access via `test.GrpcLog(t)` which returns parsed log entries |
97 | | -- Supports sanitization of secrets before writing to disk |
98 | | - |
99 | | -**Multi-Step Tests** |
100 | | -- Use `UpdateSource(t, path)` to replace program files between operations |
101 | | -- Useful for testing update behavior, replacements, etc. |
102 | | -- Example pattern: `Up()` → `UpdateSource()` → `Up()` → assert changes |
103 | | - |
104 | | -**SDK Configuration** |
105 | | -- Node.js: Use `YarnLink("@pulumi/package")` after running `yarn link` in SDK directory |
106 | | -- Go: Use `GoModReplacement("module", "path", "to", "replacement")` to add go.mod replacements |
107 | | -- .NET/C#: |
108 | | - - Use `DotNetReference("package", "path", "to", "project")` to add project references to .csproj files |
109 | | - - Path can point to a .csproj file or a directory containing one |
110 | | - - Absolute paths are resolved automatically |
111 | | - - ProjectReference elements are added to the .csproj file on stack creation |
112 | | - - Use `DotNetBuildConfiguration("Release")` to set build configuration (Debug/Release) |
113 | | - - Sets `DOTNET_BUILD_CONFIGURATION` environment variable |
114 | | - - Default is Debug if not specified |
115 | | - - Use `DotNetTargetFramework("net8.0")` to override target framework |
116 | | - - Modifies `<TargetFramework>` element in .csproj |
117 | | - - Useful for testing across different .NET versions |
118 | | - |
119 | | -**Examples** |
120 | | -```go |
121 | | -// Basic .NET test |
122 | | -test := NewPulumiTest(t, "path/to/csharp/project") |
123 | | -up := test.Up(t) |
124 | | - |
125 | | -// Test with local SDK reference |
126 | | -test := NewPulumiTest(t, |
127 | | - "path/to/csharp/project", |
128 | | - opttest.DotNetReference("Pulumi.Aws", "../pulumi-aws/sdk/dotnet"), |
129 | | -) |
130 | | - |
131 | | -// Test with specific framework and configuration |
132 | | -test := NewPulumiTest(t, |
133 | | - "path/to/csharp/project", |
134 | | - opttest.DotNetTargetFramework("net7.0"), |
135 | | - opttest.DotNetBuildConfiguration("Release"), |
136 | | -) |
137 | | -``` |
138 | | - |
139 | | -### Environment Variables |
140 | | - |
141 | | -| Variable | Purpose | |
142 | | -|----------|---------| |
143 | | -| `CI` | Adjusts defaults for CI environment (affects file retention) | |
144 | | -| `PULUMITEST_RETAIN_FILES` | Set to `true` to always retain temp directories | |
145 | | -| `PULUMITEST_RETAIN_FILES_ON_FAILURE` | Retain temp files on test failure (default: `true` locally, `false` in CI) | |
146 | | -| `PULUMITEST_SKIP_DESTROY_ON_FAILURE` | Skip automatic destroy on test failure (default: `false`) | |
147 | | -| `PULUMITEST_TEMP_DIR` | Custom temp directory instead of OS default | |
148 | | -| `PULUMI_CONFIG_PASSPHRASE` | Override default passphrase (defaults to "correct horse battery staple") | |
149 | | -| `PULUMI_BACKEND_URL` | Override default local backend | |
| 83 | + |
| 84 | + |
150 | 85 |
|
151 | 86 | ### Subdirectories |
152 | 87 |
|
@@ -200,13 +135,9 @@ test := NewPulumiTest(t, |
200 | 135 |
|
201 | 136 | **Target Framework Not Found** |
202 | 137 | - Error: `Framework 'Microsoft.NETCore.App', version 'X.X.X' not found` |
203 | | -- Solution: Install the required .NET SDK version or use `DotNetTargetFramework()` to specify an installed version |
| 138 | +- Solution: Install the required .NET SDK version |
204 | 139 | - Check installed versions: `dotnet --list-sdks` |
205 | 140 |
|
206 | | -**Build Configuration Issues** |
207 | | -- If builds are slow or producing unexpected results, explicitly set: `DotNetBuildConfiguration("Release")` |
208 | | -- Debug builds include more information but are larger and slower |
209 | | - |
210 | 141 | **Project Reference Resolution** |
211 | 142 | - Ensure referenced projects use compatible target frameworks |
212 | 143 | - Use absolute paths or paths relative to the test working directory |
|
0 commit comments