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
9d555a27
Commit
9d555a27
authored
Feb 23, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
503c430b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
13 deletions
+55
-13
t/neo/storage/fs1/filestorage_test.go
t/neo/storage/fs1/filestorage_test.go
+54
-12
t/neo/zodb/zodb.go
t/neo/zodb/zodb.go
+1
-1
No files found.
t/neo/storage/fs1/filestorage_test.go
View file @
9d555a27
...
...
@@ -9,6 +9,12 @@ import (
"../../zodb"
)
// one database transaction record
type
dbEntry
struct
{
Header
TxnHeader
Entryv
[]
txnEntry
}
// one entry inside transaction
type
txnEntry
struct
{
Header
DataHeader
...
...
@@ -16,6 +22,7 @@ type txnEntry struct {
userData
[]
byte
// data client should see on load; nil means same as RawData
}
// Data returns data a client should see
func
(
txe
*
txnEntry
)
Data
()
[]
byte
{
data
:=
txe
.
userData
if
data
==
nil
{
...
...
@@ -24,9 +31,27 @@ func (txe *txnEntry) Data() []byte {
return
data
}
type
dbEntry
struct
{
Header
TxnHeader
Entryv
[]
txnEntry
// successfull result of load for an oid
type
oidLoadedOk
struct
{
tid
zodb
.
Tid
data
[]
byte
}
// current knowledge of what was "before" for an oid as we scan over
// data base entries
type
beforeMap
map
[
zodb
.
Oid
]
oidLoadedOk
func
checkLoad
(
t
*
testing
.
T
,
fs
*
FileStorage
,
xid
zodb
.
Xid
,
expect
oidLoadedOk
)
{
data
,
tid
,
err
:=
fs
.
Load
(
xid
)
if
err
!=
nil
{
t
.
Errorf
(
"load %v: %v"
,
xid
,
err
)
}
if
tid
!=
expect
.
tid
{
t
.
Errorf
(
"load %v: returned tid unexpected: %v ; want: %v"
,
xid
,
tid
,
expect
.
tid
)
}
if
!
bytes
.
Equal
(
data
,
expect
.
data
)
{
t
.
Errorf
(
"load %v: different data:
\n
have: %q
\n
want: %q"
,
xid
,
data
,
expect
.
data
)
}
}
func
TestLoad
(
t
*
testing
.
T
)
{
...
...
@@ -35,22 +60,39 @@ func TestLoad(t *testing.T) {
t
.
Fatal
(
err
)
}
before
:=
beforeMap
{}
for
_
,
dbe
:=
range
_1fs_dbEntryv
{
for
_
,
txe
:=
range
dbe
.
Entryv
{
txh
:=
txe
.
Header
// loadSerial
xid
:=
zodb
.
Xid
{
zodb
.
XTid
{
txh
.
Tid
,
false
},
txh
.
Oid
}
data
,
tid
,
err
:=
fs
.
Load
(
xid
)
if
err
!=
nil
{
t
.
Errorf
(
"load %v: %v"
,
xid
,
err
)
}
if
tid
!=
txh
.
Tid
{
t
.
Errorf
(
"load %v: returned tid unexpected: %v"
,
xid
,
tid
)
}
if
!
bytes
.
Equal
(
data
,
txe
.
Data
())
{
t
.
Errorf
(
"load %v: different data:
\n
have: %q
\n
want: %q"
,
xid
,
data
,
txe
.
Data
())
checkLoad
(
t
,
fs
,
xid
,
oidLoadedOk
{
txh
.
Tid
,
txe
.
Data
()})
//data, tid, err := fs.Load(xid)
//if err != nil {
// t.Errorf("load %v: %v", xid, err)
//}
//if tid != txh.Tid {
// t.Errorf("load %v: returned tid unexpected: %v", xid, tid)
//}
//if !bytes.Equal(data, txe.Data()) {
// t.Errorf("load %v: different data:\nhave: %q\nwant: %q", xid, data, txe.Data())
//}
// loadBefore
// TODO also test loadBefore (TixMax)
xid
=
zodb
.
Xid
{
zodb
.
XTid
{
txh
.
Tid
,
true
},
txh
.
Oid
}
expect
,
ok
:=
before
[
txh
.
Oid
]
// TODO also test for getting error when !ok
if
ok
{
checkLoad
(
t
,
fs
,
xid
,
expect
)
}
before
[
txh
.
Oid
]
=
oidLoadedOk
{
txh
.
Tid
,
txe
.
Data
()}
}
}
}
t/neo/zodb/zodb.go
View file @
9d555a27
...
...
@@ -83,7 +83,7 @@ type ErrXidMissing struct {
}
func
(
e
*
ErrXidMissing
)
Error
()
string
{
return
fmt
.
Sprintf
(
"
"
)
// TODO
return
fmt
.
Sprintf
(
"
%v: no matching data record found"
,
e
.
Xid
)
// XXX ok?
}
// ----------------------------------------
...
...
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