test: Fix unreachable code warning in panic recovery test
Refactor the test to avoid unreachable code after panic by checking a flag set before the panic instead of after. This resolves the go vet warning while maintaining test coverage.
This commit is contained in:
parent
2bcdeea537
commit
0bcaa41499
1 changed files with 4 additions and 4 deletions
|
|
@ -686,14 +686,14 @@ func TestRecoverFromPanic(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("code after panic is not executed", func(t *testing.T) {
|
t.Run("code after panic is not executed", func(t *testing.T) {
|
||||||
afterPanicExecuted := false
|
panicReached := false
|
||||||
func() {
|
func() {
|
||||||
defer recoverFromPanic("test-goroutine")
|
defer recoverFromPanic("test-goroutine")
|
||||||
|
panicReached = true
|
||||||
panic("stop here")
|
panic("stop here")
|
||||||
afterPanicExecuted = true //nolint:govet // unreachable code is intentional for test
|
|
||||||
}()
|
}()
|
||||||
if afterPanicExecuted {
|
if !panicReached {
|
||||||
t.Error("expected code after panic to not execute")
|
t.Error("expected panic to be reached")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue