mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 02:31:04 +01:00
go1.19: core/errgroup minor fix
This commit is contained in:
parent
057fa462f4
commit
0d86a9628d
|
@ -147,7 +147,7 @@ func (e *Error) As(target interface{}) bool {
|
|||
}
|
||||
}
|
||||
|
||||
return errors.As(e.Err, &te.Err)
|
||||
return errors.As(te.Err, &e)
|
||||
}
|
||||
|
||||
return ok
|
||||
|
|
|
@ -32,13 +32,22 @@ func TestErrorIs(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// errorString is a trivial implementation of error.
|
||||
type errorString struct {
|
||||
s string
|
||||
}
|
||||
|
||||
func (e *errorString) Error() string {
|
||||
return e.s
|
||||
}
|
||||
|
||||
func TestErrorAs(t *testing.T) {
|
||||
testErr := errors.New("as")
|
||||
testErr := &errorString{"as"}
|
||||
err := &Error{Err: testErr}
|
||||
if expected, got := true, errors.As(err, &testErr); expected != got {
|
||||
t.Fatalf("[testErr as err] expected %v but got %v", expected, got)
|
||||
}
|
||||
if expected, got := true, errors.As(testErr, &err); expected != got {
|
||||
if expected, got := false, errors.As(testErr, &err); expected != got /* errorString does not implemeny As, so the std/default functionality will be applied */ {
|
||||
t.Fatalf("[err as testErr] expected %v but got %v", expected, got)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user