Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
09d4b801
Commit
09d4b801
authored
Mar 03, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
6b2d1781
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
20 deletions
+46
-20
t/neo/storage/fs1/filestorage_test.go
t/neo/storage/fs1/filestorage_test.go
+46
-20
No files found.
t/neo/storage/fs1/filestorage_test.go
View file @
09d4b801
...
...
@@ -123,60 +123,86 @@ func TestLoad(t *testing.T) {
// iterate tidMin..tidMax and expect db entries in expectv
func
testIterate
(
t
*
testing
.
T
,
fs
*
FileStorage
,
tidMin
,
tidMax
zodb
.
Tid
,
expectv
[]
dbEntry
)
{
iter
:=
fs
.
Iterate
(
tidMin
,
tidMax
)
fsi
:=
iter
.
(
*
iterator
)
for
k
:=
0
;
;
k
++
{
subj
:=
fmt
.
Sprintf
(
"iterating %v..%v: step %v/%v"
,
tidMin
,
tidMax
,
k
+
1
,
len
(
expectv
))
txnErrorf
:=
func
(
format
string
,
a
...
interface
{})
{
subj
:=
fmt
.
Sprintf
(
"iterating %v..%v: step %v/%v:"
,
tidMin
,
tidMax
,
k
+
1
,
len
(
expectv
))
msg
:=
fmt
.
Sprintf
(
format
,
a
...
)
t
.
Errorf
(
"%v: %v"
,
subj
,
msg
)
}
txni
,
dataIter
,
err
:=
iter
.
NextTxn
()
if
err
!=
nil
{
if
err
==
io
.
EOF
{
if
k
!=
len
(
expectv
)
{
t
.
Errorf
(
"%v: steps underrun"
,
subj
)
t
xnErrorf
(
"steps underrun"
)
}
break
}
t
.
Errorf
(
"%v: %v"
,
subj
,
err
)
t
xnErrorf
(
"%v"
,
err
)
}
if
k
>=
len
(
expectv
)
{
t
.
Errorf
(
"%v: steps overrun"
,
subj
)
t
xnErrorf
(
"steps overrun"
)
}
dbe
:=
expectv
[
k
]
// TODO also check .Pos, .LenPrev, .Len in iter.txnIter.*
if
!
reflect
.
DeepEqual
(
*
txni
,
dbe
.
Header
.
TxnInfo
)
{
t
.
Errorf
(
"%v: unexpected txn entry:
\n
have: %q
\n
want: %q"
,
subj
,
*
txni
,
dbe
.
Header
.
TxnInfo
)
// assert txni points to where we expect - this will allow us
// not only to check .TxnInfo but also .Pos, .LenPrev, .Len etc in
// whole expected TxnHeader
if
txni
!=
&
fsi
.
txnIter
.
Txnh
.
TxnInfo
{
t
.
Fatal
(
"unexpected txni pointer"
)
}
if
!
reflect
.
DeepEqual
(
fsi
.
txnIter
.
Txnh
,
dbe
.
Header
)
{
txnErrorf
(
"unexpected txn entry:
\n
have: %q
\n
want: %q"
,
fsi
.
txnIter
.
Txnh
,
dbe
.
Header
)
}
ndata
:=
len
(
dbe
.
Entryv
)
for
kdata
:=
0
;
;
kdata
++
{
dsubj
:=
fmt
.
Sprintf
(
"%v: dstep %v/%v"
,
subj
,
kdata
,
ndata
)
dataErrorf
:=
func
(
format
string
,
a
...
interface
{})
{
dsubj
:=
fmt
.
Sprintf
(
"dstep %v/%v"
,
kdata
,
len
(
dbe
.
Entryv
))
msg
:=
fmt
.
Sprintf
(
format
,
a
...
)
txnErrorf
(
"%v: %v"
,
dsubj
,
msg
)
}
datai
,
err
:=
dataIter
.
NextData
()
if
err
!=
nil
{
if
err
==
io
.
EOF
{
if
kdata
!=
ndata
{
t
.
Errorf
(
"%v: data steps underrun"
,
dsubj
)
if
kdata
!=
len
(
dbe
.
Entryv
)
{
dataErrorf
(
"dsteps underrun"
)
}
break
}
t
.
Errorf
(
"%v: %v"
,
dsubj
,
err
)
dataErrorf
(
"%v"
,
err
)
}
if
kdata
>
ndata
{
t
.
Errorf
(
"%v: dsteps overrun"
,
dsubj
)
if
kdata
>
len
(
dbe
.
Entryv
)
{
dataErrorf
(
"dsteps overrun"
)
}
txe
:=
dbe
.
Entryv
[
kdata
]
dh
:=
txe
.
Header
// assert datai pointes to where we expect - this will allow us
// not only to check oid/tid/data but also to check whole data header.
if
datai
!=
&
fsi
.
dataIter
.
sri
{
t
.
Fatal
(
"unexpected datai pointer"
)
}
if
!
reflect
.
DeepEqual
(
fsi
.
dataIter
.
Datah
,
dh
)
{
dataErrorf
(
"unexpected data entry:
\n
have: %q
\n
want: %q"
,
fsi
.
dataIter
.
Datah
,
dh
)
}
//
XXX -> func
if
datai
.
Oid
!=
txe
.
Header
.
Oid
{
t
.
Errorf
(
"%v: oid mismatch ..."
,
dsubj
)
// XXX
//
check what was actually returned - since it is not in ^^^ data structure
if
datai
.
Oid
!=
dh
.
Oid
{
dataErrorf
(
"oid mismatch: have %v; want %v"
,
datai
.
Oid
,
dh
.
Oid
)
}
if
datai
.
Tid
!=
txe
.
Header
.
Tid
{
t
.
Errorf
(
"%v: tid mismatch ..."
,
dsubj
)
// XXX
if
datai
.
Tid
!=
dh
.
Tid
{
dataErrorf
(
"tid mismatch: have %v; want %v"
,
datai
.
Tid
,
dh
.
Tid
)
}
if
!
bytes
.
Equal
(
datai
.
Data
,
txe
.
Data
())
{
t
.
Errorf
(
"%v: data mismatch ..."
,
dsubj
)
// XXX
dataErrorf
(
"data mismatch:
\n
have %q
\n
want %q"
,
datai
.
Data
,
txe
.
Data
())
}
// TODO .DataTid
...
...
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