1
0
mirror of https://github.com/go-kratos/kratos.git synced 2024-12-24 20:14:48 +02:00
kratos/errors/wrap_test.go
haiyux 00c05e82a3
test:remove testify go mod (#1766)
* test:remove testify go mod

* tidy go mdo

* fix test
2022-01-14 10:02:42 +08:00

28 lines
504 B
Go

package errors
import (
"fmt"
"testing"
)
type mockErr struct{}
func (*mockErr) Error() string {
return "mock error"
}
func TestWarp(t *testing.T) {
var err error = &mockErr{}
err2 := fmt.Errorf("wrap %w", err)
if err != Unwrap(err2) {
t.Errorf("got %v want: %v", err, Unwrap(err2))
}
if !Is(err2, err) {
t.Errorf("Is(err2, err) got %v want: %v", Is(err2, err), true)
}
err3 := &mockErr{}
if !As(err2, &err3) {
t.Errorf("As(err2, &err3) got %v want: %v", As(err2, &err3), true)
}
}