go-zero/core/threading/routines_test.go
Kevin Wan d935c83a54
feat: support baggage propagation in httpc (#2375)
* feat: support baggage propagation in httpc

* chore: use go 1.16

* chore: use go 1.16

* chore: use go ^1.16

* chore: remove deprecated
2022-09-10 15:18:52 +08:00

37 lines
468 B
Go

package threading
import (
"io"
"log"
"testing"
"github.com/stretchr/testify/assert"
"github.com/zeromicro/go-zero/core/lang"
)
func TestRoutineId(t *testing.T) {
assert.True(t, RoutineId() > 0)
}
func TestRunSafe(t *testing.T) {
log.SetOutput(io.Discard)
i := 0
defer func() {
assert.Equal(t, 1, i)
}()
ch := make(chan lang.PlaceholderType)
go RunSafe(func() {
defer func() {
ch <- lang.Placeholder
}()
panic("panic")
})
<-ch
i++
}