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
9d555a27
Commit
9d555a27
authored
7 years ago
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
503c430b
No related merge requests found
Changes
2
Hide 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 (
...
@@ -9,6 +9,12 @@ import (
"../../zodb"
"../../zodb"
)
)
// one database transaction record
type
dbEntry
struct
{
Header
TxnHeader
Entryv
[]
txnEntry
}
// one entry inside transaction
// one entry inside transaction
type
txnEntry
struct
{
type
txnEntry
struct
{
Header
DataHeader
Header
DataHeader
...
@@ -16,6 +22,7 @@ type txnEntry struct {
...
@@ -16,6 +22,7 @@ type txnEntry struct {
userData
[]
byte
// data client should see on load; nil means same as RawData
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
{
func
(
txe
*
txnEntry
)
Data
()
[]
byte
{
data
:=
txe
.
userData
data
:=
txe
.
userData
if
data
==
nil
{
if
data
==
nil
{
...
@@ -24,9 +31,27 @@ func (txe *txnEntry) Data() []byte {
...
@@ -24,9 +31,27 @@ func (txe *txnEntry) Data() []byte {
return
data
return
data
}
}
type
dbEntry
struct
{
// successfull result of load for an oid
Header
TxnHeader
type
oidLoadedOk
struct
{
Entryv
[]
txnEntry
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
)
{
func
TestLoad
(
t
*
testing
.
T
)
{
...
@@ -35,22 +60,39 @@ func TestLoad(t *testing.T) {
...
@@ -35,22 +60,39 @@ func TestLoad(t *testing.T) {
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
before
:=
beforeMap
{}
for
_
,
dbe
:=
range
_1fs_dbEntryv
{
for
_
,
dbe
:=
range
_1fs_dbEntryv
{
for
_
,
txe
:=
range
dbe
.
Entryv
{
for
_
,
txe
:=
range
dbe
.
Entryv
{
txh
:=
txe
.
Header
txh
:=
txe
.
Header
// loadSerial
// loadSerial
xid
:=
zodb
.
Xid
{
zodb
.
XTid
{
txh
.
Tid
,
false
},
txh
.
Oid
}
xid
:=
zodb
.
Xid
{
zodb
.
XTid
{
txh
.
Tid
,
false
},
txh
.
Oid
}
data
,
tid
,
err
:=
fs
.
Load
(
xid
)
checkLoad
(
t
,
fs
,
xid
,
oidLoadedOk
{
txh
.
Tid
,
txe
.
Data
()})
if
err
!=
nil
{
//data, tid, err := fs.Load(xid)
t
.
Errorf
(
"load %v: %v"
,
xid
,
err
)
//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 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
())
//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
()}
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
t/neo/zodb/zodb.go
View file @
9d555a27
...
@@ -83,7 +83,7 @@ type ErrXidMissing struct {
...
@@ -83,7 +83,7 @@ type ErrXidMissing struct {
}
}
func
(
e
*
ErrXidMissing
)
Error
()
string
{
func
(
e
*
ErrXidMissing
)
Error
()
string
{
return
fmt
.
Sprintf
(
"
"
)
// TODO
return
fmt
.
Sprintf
(
"
%v: no matching data record found"
,
e
.
Xid
)
// XXX ok?
}
}
// ----------------------------------------
// ----------------------------------------
...
...
This diff is collapsed.
Click to expand it.
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