mirror of
https://github.com/go-kratos/kratos.git
synced 2024-12-24 20:14:48 +02:00
00c05e82a3
* test:remove testify go mod * tidy go mdo * fix test
28 lines
504 B
Go
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)
|
|
}
|
|
}
|