Return subscription from channel-preview [skip-tests]
This commit is contained in:
@@ -306,6 +306,22 @@ func AssertAny(v any) {
|
||||
// used to prevent golang "unused variable error"
|
||||
}
|
||||
|
||||
func AssertNil(t *testing.T, key string, v any) {
|
||||
if v != nil {
|
||||
t.Errorf("AssertNil(%s) failed - actual value:\n%+v", key, v)
|
||||
t.Error(string(debug.Stack()))
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
func AssertNotNil(t *testing.T, key string, v any) {
|
||||
if v == nil {
|
||||
t.Errorf("AssertNotNil(%s) failed", key)
|
||||
t.Error(string(debug.Stack()))
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
func unpointer(v any) any {
|
||||
if v == nil {
|
||||
return v
|
||||
|
||||
@@ -125,6 +125,18 @@ func assertjsonStructureMatchSingleValue(t *testing.T, strschema string, realVal
|
||||
t.Errorf("Key < %s > is not a int (its actually %T: '%v')", keyPath, realValue, realValue)
|
||||
return
|
||||
}
|
||||
case "object|null":
|
||||
if langext.IsNil(realValue) {
|
||||
return // OK
|
||||
}
|
||||
if _, ok := realValue.(map[string]any); !ok {
|
||||
t.Errorf("Key < %s > is not an object|null (its actually %T: '%v')", keyPath, realValue, realValue)
|
||||
return
|
||||
}
|
||||
if _, err := time.Parse(time.RFC3339, realValue.(string)); err != nil {
|
||||
t.Errorf("Key < %s > is not an object|null (its '%v')", keyPath, realValue)
|
||||
return
|
||||
}
|
||||
default:
|
||||
t.Errorf("Unknown schema type '%s' for key < %s >", strschema, keyPath)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user