Factor out error type checks
This commit is contained in:
1 parent
0a5990bd6e
commit
94a812d98f
3 files changed
+20
-15
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package weavedns
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -15,3 +16,17 @@ func assertStatus(t *testing.T, got int, wanted int, desc string) {
|
||||
t.Fatalf("Expected %s %d but got %d", desc, wanted, got)
|
||||
}
|
||||
}
|
||||
|
||||
func assertErrorInterface(t *testing.T, got interface{}, wanted interface{}, desc string) {
|
||||
got_t, wanted_t := reflect.TypeOf(got), reflect.TypeOf(wanted).Elem()
|
||||
if !got_t.Implements(wanted_t) {
|
||||
t.Fatalf("Expected %s but got %s (%s)", wanted_t.String(), got_t.String(), desc)
|
||||
}
|
||||
}
|
||||
|
||||
func assertErrorType(t *testing.T, got interface{}, wanted interface{}, desc string) {
|
||||
got_t, wanted_t := reflect.TypeOf(got), reflect.TypeOf(wanted).Elem()
|
||||
if got_t != wanted_t {
|
||||
t.Fatalf("Expected %s but got %s (%s)", wanted_t.String(), got_t.String(), desc)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user