mirror of
https://github.com/hanzoai/tasks.git
synced 2026-11-03 03:56:04 +00:00
## What changed? Integrate Go 1.26's new `go fix` into workflow. NOTE that the changes caused our linter to fire; a [separate commit](https://github.com/temporalio/temporal/pull/9337/commits/1b23f787aef370098b35829c4d17dcc06230b4c1) addresses those. ## Why? Ensure Go code is standardized/modernized. ## How did you test it? - [ ] built - [ ] run locally and tested manually - [x] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s)
30 lines
534 B
Go
30 lines
534 B
Go
package log
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestCapturePanic(t *testing.T) {
|
|
fooErr := testCapture("foo")
|
|
assert.Error(t, fooErr)
|
|
assert.Equal(t, "panic: foo", fooErr.Error())
|
|
|
|
barErr := testCapture(fmt.Errorf("error: %v", "bar"))
|
|
assert.Error(t, barErr)
|
|
assert.Equal(t, "error: bar", barErr.Error())
|
|
}
|
|
|
|
func testCapture(panicObj any) (retErr error) {
|
|
defer CapturePanic(NewNoopLogger(), &retErr)
|
|
|
|
testPanic(panicObj)
|
|
return nil
|
|
}
|
|
|
|
func testPanic(panicObj any) {
|
|
panic(panicObj)
|
|
}
|