Skip to content

Commit 0a00113

Browse files
bergmannfclaude
andcommitted
Update CHGM tests to work with executor action pattern
This commit updates all 28 test cases in the CHGM investigation to verify the new executor action pattern instead of mocking direct OCM/PagerDuty calls. **Test infrastructure updates:** 1. **Added helper functions:** - hasActionType() - Generic action type checker - hasLimitedSupportAction() - Check for limited support actions - hasSilenceAction() - Check for silence incident actions - hasEscalateAction() - Check for escalate incident actions - hasServiceLogAction() - Check for service log actions - hasNoteAction() - Check for PagerDuty note actions 2. **Removed old mock expectations:** - Removed all .EXPECT().PostLimitedSupportReason() calls - Removed all .EXPECT().SilenceIncidentWithNote() calls - Removed all .EXPECT().EscalateIncidentWithNote() calls - Removed all .EXPECT().PostServiceLog() calls 3. **Updated test expectations:** - Tests expecting limited support now verify LS + Silence + Note actions - Tests expecting escalation now verify Escalate + Note actions - Infrastructure error tests verify error is returned (no actions) - Investigation finding tests verify actions are returned (no error) 4. **Fixed isInfrastructureError() helper:** - Added CloudTrail parsing errors to investigation findings: * "could not extractUserDetails" * "failed to parse CloudTrail event version" * "cannot parse a nil input" - These are data quality issues, not transient infrastructure failures - Should be reported via actions, not retried **Test results:** ✅ All 28 tests passing - 24 tests verify action-based outcomes - 2 tests verify infrastructure error returns - 2 tests verify investigation finding escalations **Benefits:** - Tests now verify behavior (what actions are taken) not implementation (which mock methods are called) - More resilient to refactoring - don't break when internal calls change - Easier to understand - test assertions match user-visible outcomes - Consistent with executor pattern - actions are the contract 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 7086f1d commit 0a00113

File tree

2 files changed

+130
-44
lines changed

2 files changed

+130
-44
lines changed

pkg/investigations/chgm/chgm.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ func isInfrastructureError(err error) bool {
6969
"stopped instances but no stoppedInstancesEvents", // CloudTrail data too old
7070
"clusterdeployment is empty", // Data missing but not retriable
7171
"no non running instances found", // Investigation finding
72+
"could not extractUserDetails", // Invalid CloudTrail event data
73+
"failed to parse CloudTrail event version", // Invalid CloudTrail event data
74+
"cannot parse a nil input", // Invalid CloudTrail event data
7275
}
7376

7477
for _, pattern := range findingPatterns {

0 commit comments

Comments
 (0)