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
82746330
Commit
82746330
authored
Jul 31, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
c219652d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
26 deletions
+18
-26
go/zodb/persistent_test.go
go/zodb/persistent_test.go
+18
-26
No files found.
go/zodb/persistent_test.go
View file @
82746330
...
...
@@ -24,6 +24,7 @@ import (
"reflect"
"testing"
"lab.nexedi.com/kirr/go123/mem"
"github.com/stretchr/testify/require"
)
...
...
@@ -56,6 +57,9 @@ func init() {
}
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
,
loading
*
loadState
)
{
xbase
:=
reflect
.
ValueOf
(
obj
)
.
Elem
()
.
FieldByName
(
"Persistent"
)
pbase
:=
xbase
.
Addr
()
.
Interface
()
.
(
*
Persistent
)
...
...
@@ -87,7 +91,20 @@ func TestPersistent(t *testing.T) {
// XXX loading too?
}
xobj
:=
newGhost
(
"t.zodb.MyObject"
,
11
,
nil
)
// unknown type -> Broken
xobj
:=
newGhost
(
"t.unknown"
,
10
,
nil
)
b
,
ok
:=
xobj
.
(
*
Broken
)
if
!
ok
{
t
.
Fatalf
(
"unknown -> %T; want Broken"
,
xobj
)
}
checkObj
(
b
,
nil
,
10
,
0
,
GHOST
,
0
,
nil
)
assert
.
Equal
(
b
.
class
,
"t.unknown"
)
assert
.
Equal
(
b
.
state
,
(
*
mem
.
Buf
)(
nil
))
// t.zodb.MyObject -> *MyObject
xobj
=
newGhost
(
"t.zodb.MyObject"
,
11
,
nil
)
obj
,
ok
:=
xobj
.
(
*
MyObject
)
if
!
ok
{
t
.
Fatalf
(
"unknown -> %T; want Broken"
,
xobj
)
...
...
@@ -101,28 +118,3 @@ func TestPersistent(t *testing.T) {
// TODO deactivate - refcnt--
// TODO deactivate - state dropped
}
// 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
,
(
*
Connection
)(
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