Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
e7efba73
Commit
e7efba73
authored
Jul 31, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
6450154d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
4 deletions
+46
-4
go/zodb/persistent.go
go/zodb/persistent.go
+2
-2
go/zodb/persistent_test.go
go/zodb/persistent_test.go
+44
-2
No files found.
go/zodb/persistent.go
View file @
e7efba73
...
@@ -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 no
t
// Broken objects are used to represent
loaded ZODB objects with classes tha
t
// 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
{
...
...
go/zodb/persistent_test.go
View file @
e7efba73
...
@@ -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
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment