Commit e7efba73 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 6450154d
...@@ -432,8 +432,8 @@ func newGhost(class string, oid Oid, jar *Connection) IPersistent { ...@@ -432,8 +432,8 @@ func newGhost(class string, oid Oid, jar *Connection) IPersistent {
return base.instance return base.instance
} }
// Broken objects are used to represent ZODB objects with classes that were not // Broken objects are used to represent loaded ZODB objects with classes that
// registered to zodb Go package. // were not registered to zodb Go package.
// //
// See RegisterClass for details. // See RegisterClass for details.
type Broken struct { type Broken struct {
......
...@@ -23,8 +23,11 @@ import ( ...@@ -23,8 +23,11 @@ import (
"fmt" "fmt"
"reflect" "reflect"
"testing" "testing"
"github.com/stretchr/testify/require"
) )
// test Persistent type.
type MyObject struct { type MyObject struct {
Persistent Persistent
...@@ -52,8 +55,47 @@ func init() { ...@@ -52,8 +55,47 @@ func init() {
RegisterClass("t.zodb.MyObject", t(MyObject{}), t(myObjectState{})) RegisterClass("t.zodb.MyObject", t(MyObject{}), t(myObjectState{}))
} }
func TestPersistent(t *testing.T) {
assert := require.New(t)
xobj := newGhost("t.zodb.MyObject", 11, nil)
func TestPersistent(t *testing.T) { obj, ok := xobj.(*MyObject)
// XXX if !ok {
t.Fatalf("unknown -> %T; want Broken", xobj)
}
// XXX .zclass ?
assert.Equal(obj.jar, nil)
assert.Equal(obj.oid, 11)
assert.Equal(obj.serial, 0)
assert.Equal(obj.state, GHOST)
assert.Equal(obj.refcnt, 0)
assert.Equal(obj.instance, obj)
assert.Equal(obj.loading, nil)
}
// XXX reenable
func _TestBroken(t *testing.T) {
assert := require.New(t)
// unknown type -> Broken
xobj := newGhost("t.unknown", 11, nil)
obj, ok := xobj.(*Broken)
if !ok {
t.Fatalf("unknown -> %T; want Broken", xobj)
}
// XXX .zclass ?
assert.Equal(obj.class, "t.unknown")
assert.Equal(obj.state, nil)
assert.Equal(obj.jar, nil)
assert.Equal(obj.oid, 11)
assert.Equal(obj.serial, 0)
assert.Equal(obj.state, GHOST)
assert.Equal(obj.refcnt, 0)
assert.Equal(obj.instance, obj)
assert.Equal(obj.loading, 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