Commit a17b265
test: dedup test framework (dagger#157)
* refactor: introduce globalConfigPath for cleaner test isolation
The previous OpenWithBasePath approach exposed test implementation details
in the public API. This change uses a function variable pattern to allow
tests to override the config path without polluting the API.
Production code remains unaware of test-specific concerns while tests get
the isolation they need.
Trade-off: SetTestConfigPath() modifies global state, so tests using it
cannot run in parallel.
Signed-off-by: Guillaume de Rouville <guillaume@dagger.io>
* test: remove t.Parallel() calls to support SetTestConfigPath
SetTestConfigPath modifies global state, making it incompatible with
parallel test execution. Remove all t.Parallel() calls from integration
tests to ensure tests run sequentially and avoid race conditions.
Signed-off-by: Guillaume de Rouville <guillaume@dagger.io>
* refactor: extract WriteEnvironmentFile from MCP handler
Extract the core logic from environment_file_write handler into a public
function that can be used by both the MCP handler and test helpers.
This eliminates duplication between the handler and test helpers while
maintaining the same behavior. The handler now acts as a thin wrapper
that handles MCP-specific concerns (parameter extraction, error formatting)
while the business logic lives in the extracted function.
Signed-off-by: Guillaume de Rouville <guillaume@dagger.io>
* refactor: extract DeleteEnvironmentFile from MCP handler
Extract the core logic from environment_file_delete handler into a public
function. This follows the same pattern as WriteEnvironmentFile, allowing
both the MCP handler and test helpers to use the same implementation.
The handler preserves the original error message for compatibility.
Signed-off-by: Guillaume de Rouville <guillaume@dagger.io>
* refactor: extract ReadEnvironmentFile from MCP handler
Extract the core logic from environment_file_read handler. This is a
read-only operation that doesn't update the repository, making it simpler
than the write operations.
The handler now uses err.Error() for the error message to preserve the
original behavior where different errors could occur.
Signed-off-by: Guillaume de Rouville <guillaume@dagger.io>
* refactor: extract RunEnvironmentCommand from MCP handler
Extract the core logic from environment_run_cmd handler. This handles both
foreground and background command execution, including the repository update
that must happen even if the command fails.
The function returns 'any' to accommodate both string output (foreground)
and endpoint mappings (background). The handler formats the appropriate
response based on the command type.
Signed-off-by: Guillaume de Rouville <guillaume@dagger.io>
* refactor: extract CreateEnvironment from MCP handler
Extract the core logic from environment_create handler. This simplifies
the handler to focus on MCP-specific concerns while the business logic
lives in the extracted function.
The handler preserves the original 'failed to create environment' error
message for compatibility.
Signed-off-by: Guillaume de Rouville <guillaume@dagger.io>
* refactor: extract UpdateEnvironment from MCP handler
Extract the core logic from environment_update handler. This handles
updating environment configuration including title, instructions, base
image, setup commands, environment variables, and secrets.
The handler preserves the original 'unable to update the environment'
error message and the detailed success response format.
Signed-off-by: Guillaume de Rouville <guillaume@dagger.io>
* refactor: extract ListEnvironmentFiles from MCP handler
Extract the core logic from environment_file_list handler. This is a
read-only operation that lists directory contents without modifying
the environment.
The handler preserves the original 'failed to list directory' error
message for compatibility.
Signed-off-by: Guillaume de Rouville <guillaume@dagger.io>
* refactor: extract GetEnvironmentFromSource from MCP handler
Extract the core logic from environment_open handler. This is a simple
operation that opens an existing environment from a source repository.
The handler preserves the original 'unable to open the environment' error
message for compatibility.
Signed-off-by: Guillaume de Rouville <guillaume@dagger.io>
* refactor: extract AddEnvironmentService from MCP handler
Extract the core logic from environment_add_service handler. This handles
adding services (like databases, caches) to an environment including their
configuration, ports, environment variables, and secrets.
The handler preserves the original 'failed to update env' error message
that was returned when either adding the service or updating the repository
failed.
Signed-off-by: Guillaume de Rouville <guillaume@dagger.io>
* fix: CreateEnvironment returns repo to enable dirty check
The refactored CreateEnvironment function wasn't returning the repository,
preventing the handler from checking for uncommitted changes.
Return both repo and environment from CreateEnvironment to maintain the
same behavior as the original handler while keeping the extraction clean.
Signed-off-by: Guillaume de Rouville <guillaume@dagger.io>
* chore: apply go fmt
Run go fmt to fix formatting issues:
- Remove trailing whitespace
- Remove extra blank lines
- Ensure consistent formatting
Signed-off-by: Guillaume de Rouville <guillaume@dagger.io>
* fix: remove t.Parallel() from tests using SetTestConfigPath
SetTestConfigPath modifies a global variable, making it unsafe for
parallel test execution. Tests were racing and causing CI failures.
Added warning comment to WithRepository to prevent future issues.
Signed-off-by: Guillaume de Rouville <guillaume@dagger.io>
* feat: add lint check for t.Parallel() with WithRepository
Add a simple grep-based check to prevent using t.Parallel() in test
files that also use WithRepository. This prevents race conditions
caused by WithRepository's use of SetTestConfigPath global variable.
The check is file-level (not function-level) for simplicity, which
may cause false positives but ensures all real issues are caught.
Signed-off-by: Guillaume de Rouville <guillaume@dagger.io>
* chore: keep rely on the proper daggerClienKey
Signed-off-by: Guillaume de Rouville <guillaume@dagger.io>
---------
Signed-off-by: Guillaume de Rouville <guillaume@dagger.io>1 parent facdf21 commit a17b265
File tree
7 files changed
+471
-155
lines changed- .dagger
- environment/integration
- mcpserver
- repository
7 files changed
+471
-155
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
| 93 | + | |
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
96 | 144 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
38 | 43 | | |
39 | 44 | | |
40 | 45 | | |
| |||
48 | 53 | | |
49 | 54 | | |
50 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
51 | 60 | | |
52 | 61 | | |
53 | 62 | | |
| |||
66 | 75 | | |
67 | 76 | | |
68 | 77 | | |
69 | | - | |
70 | | - | |
| 78 | + | |
| 79 | + | |
71 | 80 | | |
72 | 81 | | |
73 | 82 | | |
74 | | - | |
| 83 | + | |
75 | 84 | | |
76 | 85 | | |
77 | 86 | | |
78 | 87 | | |
79 | | - | |
| 88 | + | |
80 | 89 | | |
81 | | - | |
| 90 | + | |
82 | 91 | | |
83 | 92 | | |
84 | 93 | | |
| |||
184 | 193 | | |
185 | 194 | | |
186 | 195 | | |
187 | | - | |
| 196 | + | |
188 | 197 | | |
189 | 198 | | |
190 | | - | |
| 199 | + | |
191 | 200 | | |
192 | 201 | | |
193 | 202 | | |
| |||
202 | 211 | | |
203 | 212 | | |
204 | 213 | | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
| 214 | + | |
209 | 215 | | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | 216 | | |
214 | 217 | | |
215 | 218 | | |
216 | 219 | | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
| 220 | + | |
221 | 221 | | |
| 222 | + | |
222 | 223 | | |
223 | | - | |
224 | | - | |
225 | | - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
226 | 227 | | |
227 | 228 | | |
228 | 229 | | |
229 | 230 | | |
230 | 231 | | |
231 | | - | |
| 232 | + | |
232 | 233 | | |
| 234 | + | |
233 | 235 | | |
234 | 236 | | |
235 | 237 | | |
236 | 238 | | |
237 | 239 | | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
| 240 | + | |
| 241 | + | |
250 | 242 | | |
251 | 243 | | |
252 | 244 | | |
253 | 245 | | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
| 246 | + | |
258 | 247 | | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | 248 | | |
263 | 249 | | |
264 | 250 | | |
265 | 251 | | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
| 252 | + | |
270 | 253 | | |
271 | 254 | | |
272 | 255 | | |
| |||
280 | 263 | | |
281 | 264 | | |
282 | 265 | | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
283 | 273 | | |
284 | 274 | | |
285 | 275 | | |
| |||
288 | 278 | | |
289 | 279 | | |
290 | 280 | | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
291 | 297 | | |
292 | 298 | | |
293 | 299 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | 21 | | |
23 | 22 | | |
24 | 23 | | |
| |||
61 | 60 | | |
62 | 61 | | |
63 | 62 | | |
64 | | - | |
65 | 63 | | |
66 | 64 | | |
67 | 65 | | |
| |||
106 | 104 | | |
107 | 105 | | |
108 | 106 | | |
109 | | - | |
110 | 107 | | |
111 | 108 | | |
112 | 109 | | |
| |||
183 | 180 | | |
184 | 181 | | |
185 | 182 | | |
186 | | - | |
187 | 183 | | |
188 | 184 | | |
189 | 185 | | |
| |||
216 | 212 | | |
217 | 213 | | |
218 | 214 | | |
219 | | - | |
220 | 215 | | |
221 | 216 | | |
222 | 217 | | |
| |||
256 | 251 | | |
257 | 252 | | |
258 | 253 | | |
259 | | - | |
260 | 254 | | |
261 | 255 | | |
262 | 256 | | |
| |||
400 | 394 | | |
401 | 395 | | |
402 | 396 | | |
403 | | - | |
404 | 397 | | |
405 | 398 | | |
406 | 399 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
| |||
63 | 62 | | |
64 | 63 | | |
65 | 64 | | |
66 | | - | |
67 | 65 | | |
68 | 66 | | |
69 | 67 | | |
| |||
77 | 75 | | |
78 | 76 | | |
79 | 77 | | |
80 | | - | |
81 | 78 | | |
82 | 79 | | |
83 | 80 | | |
| |||
108 | 105 | | |
109 | 106 | | |
110 | 107 | | |
111 | | - | |
112 | 108 | | |
113 | 109 | | |
114 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
| |||
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
37 | | - | |
38 | 36 | | |
39 | 37 | | |
40 | 38 | | |
| |||
56 | 54 | | |
57 | 55 | | |
58 | 56 | | |
59 | | - | |
60 | 57 | | |
61 | 58 | | |
62 | 59 | | |
| |||
81 | 78 | | |
82 | 79 | | |
83 | 80 | | |
84 | | - | |
85 | 81 | | |
86 | 82 | | |
87 | 83 | | |
| |||
106 | 102 | | |
107 | 103 | | |
108 | 104 | | |
109 | | - | |
110 | 105 | | |
111 | 106 | | |
112 | 107 | | |
| |||
131 | 126 | | |
132 | 127 | | |
133 | 128 | | |
134 | | - | |
135 | 129 | | |
136 | 130 | | |
137 | 131 | | |
| |||
170 | 164 | | |
171 | 165 | | |
172 | 166 | | |
173 | | - | |
174 | 167 | | |
175 | 168 | | |
176 | 169 | | |
| |||
0 commit comments