logtest_test.go 481 B

12345678910111213141516171819202122232425262728
  1. package logtest
  2. import (
  3. "errors"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. "github.com/zeromicro/go-zero/core/logx"
  7. )
  8. func TestCollector(t *testing.T) {
  9. const input = "hello"
  10. c := NewCollector(t)
  11. logx.Info(input)
  12. assert.Equal(t, input, c.Content())
  13. assert.Contains(t, c.String(), input)
  14. }
  15. func TestPanicOnFatal(t *testing.T) {
  16. const input = "hello"
  17. Discard(t)
  18. logx.Info(input)
  19. PanicOnFatal(t)
  20. assert.Panics(t, func() {
  21. logx.Must(errors.New("foo"))
  22. })
  23. }