Commit c90df4a
committed
refactor: add test builders for command dependencies
Implemented Proposal #4 - Test Builder Helpers
Changes:
- Added ProvisionCommandTestBuilder in provision.rs test module
- Manages TempDir lifecycle automatically
- Provides sensible defaults for all dependencies
- Returns (command, temp_dir, ssh_credentials) tuple
- Includes optional with_ssh_credentials() customization method
- Added ConfigureCommandTestBuilder in configure.rs test module
- Manages TempDir lifecycle automatically
- Provides sensible defaults for all dependencies
- Returns (command, temp_dir) tuple
- Updated 5 provision tests to use ProvisionCommandTestBuilder
- Updated 2 configure tests to use ConfigureCommandTestBuilder
- Removed old create_mock_dependencies() functions from both files
Rationale:
- Reduces test boilerplate significantly
- Eliminates confusing 8-tuple return from provision tests
- Eliminates confusing 4-tuple return from configure tests
- Self-contained builders manage their own TempDir lifecycle
- Type-safe: returns properly typed values
- Extensible: easy to add customization methods
- Maintainable: changes to dependencies don't break all tests
Impact:
- Removed ~76 lines (old create_mock_dependencies functions)
- Added ~92 lines (builder implementations)
- Net change: +16 lines
- Tests are now much more readable and maintainable
- Before: let (r1, r2, r3, r4, r5, r6, r7, r8) = create_mock_dependencies();
- After: let (command, temp_dir, ssh_credentials) = ProvisionCommandTestBuilder::new().build();
- All 100 tests passing
- All linters passing1 parent e65b168 commit c90df4a
2 files changed
+137
-200
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | 269 | | |
294 | 270 | | |
295 | 271 | | |
| |||
308 | 284 | | |
309 | 285 | | |
310 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
311 | 324 | | |
312 | 325 | | |
313 | | - | |
314 | | - | |
315 | | - | |
| 326 | + | |
316 | 327 | | |
317 | 328 | | |
318 | 329 | | |
| |||
334 | 345 | | |
335 | 346 | | |
336 | 347 | | |
337 | | - | |
338 | | - | |
339 | | - | |
| 348 | + | |
340 | 349 | | |
341 | 350 | | |
342 | 351 | | |
| |||
0 commit comments