Commit 1f4f1e99 authored by Kirill Smelkov's avatar Kirill Smelkov

go/zodb: persistent tests: Factor checkObj out of TestPersistent

We are going to use this function in other tests too.
parent 8b93cb5e
......@@ -66,11 +66,10 @@ func init() {
RegisterClassAlias("t.zodb.MyOldObject", "t.zodb.MyObject")
}
func TestPersistent(t *testing.T) {
assert := require.New(t)
// checkObj verifies current state of persistent object.
checkObj := func(obj IPersistent, jar *Connection, oid Oid, serial Tid, state ObjectState, refcnt int32) {
// checkObj verifies current state of persistent object.
//
// one can bind checkObj to t via tCheckObj.
func checkObj(t testing.TB, obj IPersistent, jar *Connection, oid Oid, serial Tid, state ObjectState, refcnt int32) {
t.Helper()
xbase := reflect.ValueOf(obj).Elem().FieldByName("Persistent")
pbase := xbase.Addr().Interface().(*Persistent)
......@@ -106,7 +105,20 @@ func TestPersistent(t *testing.T) {
if pbase.instance != obj {
badf("base.instance != obj")
}
}
// tCheckObj binds checkObj to t.
func tCheckObj(t testing.TB) func(IPersistent, *Connection, Oid, Tid, ObjectState, int32) {
return func(obj IPersistent, jar *Connection, oid Oid, serial Tid, state ObjectState, refcnt int32) {
t.Helper()
checkObj(t, obj, jar, oid, serial, state, refcnt)
}
}
func TestPersistent(t *testing.T) {
assert := require.New(t)
checkObj := tCheckObj(t)
// unknown type -> Broken
xobj := newGhost("t.unknown", 10, nil)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment