util: errwrap: Add more tests
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
package errwrap
|
package errwrap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@@ -30,6 +31,20 @@ func TestWrapfErr1(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestWrapfErr2(t *testing.T) {
|
||||||
|
reterr := fmt.Errorf("reterr")
|
||||||
|
if err := Wrapf(reterr, "whatever: %d", 42); err == nil {
|
||||||
|
t.Errorf("expected err")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWrapfErr3(t *testing.T) {
|
||||||
|
reterr := fmt.Errorf("reterr")
|
||||||
|
if err := Wrapf(reterr, "whatever: %d", 42); !errors.Is(err, reterr) {
|
||||||
|
t.Errorf("expected matching err")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestAppendErr1(t *testing.T) {
|
func TestAppendErr1(t *testing.T) {
|
||||||
if err := Append(nil, nil); err != nil {
|
if err := Append(nil, nil); err != nil {
|
||||||
t.Errorf("expected nil result")
|
t.Errorf("expected nil result")
|
||||||
|
|||||||
Reference in New Issue
Block a user