From 1a36e8407fc6fe5e6882f45a8f453cbb046f5e06 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Mar 2026 11:28:27 +0000 Subject: [PATCH 1/2] Initial plan From ff528771ef546186e2befb5bf8764e90d118f735 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Mar 2026 11:31:38 +0000 Subject: [PATCH 2/2] test: add regression test ensuring failure condition is never called with nil error Co-authored-by: costela <94699+costela@users.noreply.github.com> Agent-Logs-Url: https://github.com/exaring/hoglet/sessions/1eef0e08-4cf1-4cc3-94e6-176f2fead113 --- hoglet_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/hoglet_test.go b/hoglet_test.go index 9b9cb70..b8e4e6d 100644 --- a/hoglet_test.go +++ b/hoglet_test.go @@ -207,6 +207,25 @@ func TestHoglet_Do(t *testing.T) { } } +// TestCircuit_failure_condition_never_called_with_nil ensures that the nil guard in hoglet.go prevents +// custom failure conditions from ever receiving a nil error. +func TestCircuit_failure_condition_never_called_with_nil(t *testing.T) { + // panicOnNil is a failure condition that panics if called with nil, acting as a strict regression guard. + 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) + }) +} + // maybeAssertPanic is a test-table helper to assert that a function panics or not, depending on the value of wantPanic. func maybeAssertPanic(t *testing.T, f func(), wantPanic any) { wrapped := assert.NotPanics