Add hermetic wfctl infra tests#651
Conversation
⏱ Benchmark Results✅ No significant performance regressions detected. benchstat comparison (baseline → PR)
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Agent-Logs-Url: https://github.com/GoCodeAlone/workflow/sessions/36793334-efac-47f8-ba98-b06822f35b8c Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
Agent-Logs-Url: https://github.com/GoCodeAlone/workflow/sessions/36793334-efac-47f8-ba98-b06822f35b8c Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds a new wfctl infra test subcommand that lets config authors validate infra expectations (rendered resources, resolved inputs, and plan shape) without contacting live providers or requiring cloud credentials, plus documentation and unit tests to establish the boundary.
Changes:
- Adds
wfctl infra test <test.yaml> [test.yaml ...]and wires it intowfctl infradispatch/help. - Implements YAML-driven hermetic assertions for rendered resources, resolved provider inputs (post plan-time resolver), and config-hash-based plan actions.
- Documents the new command and provides example test syntax in
docs/WFCTL.md.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| docs/WFCTL.md | Documents wfctl infra test behavior and provides a minimal example test file. |
| cmd/wfctl/infra.go | Adds test action routing and help text under wfctl infra. |
| cmd/wfctl/infra_test_cmd.go | Implements hermetic infra test runner + assertion helpers for resources/provider inputs/plan. |
| cmd/wfctl/infra_test_cmd_test.go | Adds unit tests covering hermetic behavior and mismatch failure. |
| for _, exp := range expected.Actions { | ||
| var match *interfaces.PlanAction | ||
| for i := range actual.Actions { | ||
| action := &actual.Actions[i] | ||
| if exp.Action != "" && action.Action != exp.Action { | ||
| continue | ||
| } | ||
| if exp.Resource.Name != "" && action.Resource.Name != exp.Resource.Name { | ||
| continue | ||
| } | ||
| match = action | ||
| break | ||
| } | ||
| if match == nil { | ||
| return fmt.Errorf("plan action not found: action=%q resource=%q", exp.Action, exp.Resource.Name) | ||
| } | ||
| if exp.Resource.Type != "" && match.Resource.Type != exp.Resource.Type { | ||
| return fmt.Errorf("plan action %s resource %s type: got %q, want %q", exp.Action, exp.Resource.Name, match.Resource.Type, exp.Resource.Type) | ||
| } | ||
| if err := assertMapSubset(exp.Resource.Config, match.Resource.Config); err != nil { | ||
| return fmt.Errorf("plan action %s resource %s config: %w", exp.Action, exp.Resource.Name, err) | ||
| } | ||
| } |
|
@copilot apply changes based on the comments in this thread Need test coverage improved: #651 (comment) |
Agent-Logs-Url: https://github.com/GoCodeAlone/workflow/sessions/b552f30b-8c84-44fd-a053-84dd204d9e96 Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
Fixed in 75350fc.
Four new tests cover: used-tracking prevents double-claim, type filter blocks wrong-type match, config-subset filter blocks wrong-config match, and order-independence of expected entries. |
Workflow infra config needs a test boundary before provider-driven IaC semantics become harder to reason about. Config authors should be able to assert rendered resources, provider inputs, and plan shape without cloud credentials or live provider calls.
Infra test command
wfctl infra test <test.yaml>.Assertion model
current_statefixtures for update/delete scenarios and generated resource collections.Docs and examples
docs/WFCTL.md.Example: