Skip to content

test: add regression guard for nil-error invariant on failure conditions#24

Closed
Copilot wants to merge 2 commits into
fix/nil-error-guard-in-failure-conditionfrom
copilot/sub-pr-23
Closed

test: add regression guard for nil-error invariant on failure conditions#24
Copilot wants to merge 2 commits into
fix/nil-error-guard-in-failure-conditionfrom
copilot/sub-pr-23

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 26, 2026

The nil-check guard (err != nil && c.options.isFailure(err)) in hoglet.go establishes a contract that custom failure conditions are never invoked with nil errors, but nothing enforced this at the test level.

Changes

  • Regression test (TestCircuit_failure_condition_never_called_with_nil): registers a failure condition that panics on nil, wraps a function returning a nil error, and asserts no panic — any removal of the nil guard will cause an immediate, obvious failure.
panicOnNil := func(err error) bool {
    if err == nil {
        panic("failure condition must never be called with nil error")
    }
    return true
}

b, err := NewCircuit(nil, WithFailureCondition(panicOnNil))
require.NoError(t, err)

assert.NotPanics(t, func() {
    _, _ = Wrap(b, noop)(t.Context(), noopInSuccess)
})

⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.

Copilot AI changed the title [WIP] [WIP] Address feedback on simplifying failure conditions with nil check test: add regression guard for nil-error invariant on failure conditions Mar 26, 2026
Copilot AI requested a review from costela March 26, 2026 11:34
@costela costela closed this Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants