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
467c573c
Commit
467c573c
authored
Nov 09, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X fs1: Load of deleted oid should return "no data"
parent
35eb77b2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
21 deletions
+42
-21
go/zodb/storage/fs1/filestorage_test.go
go/zodb/storage/fs1/filestorage_test.go
+42
-21
No files found.
go/zodb/storage/fs1/filestorage_test.go
View file @
467c573c
...
...
@@ -67,28 +67,51 @@ func (txe *txnEntry) DataTid() zodb.Tid {
return
dataTid
}
// s
uccessfull result of load for an oid
type
o
idLoadedOk
struct
{
// s
tate of an object in the database for some particular revision
type
o
bjState
struct
{
tid
zodb
.
Tid
data
[]
byte
data
[]
byte
// nil if obj was deleted
}
// checkLoad verifies that fs.Load(xid) returns expected result
func
checkLoad
(
t
*
testing
.
T
,
fs
*
FileStorage
,
xid
zodb
.
Xid
,
expect
oidLoadedOk
)
{
func
checkLoad
(
t
*
testing
.
T
,
fs
*
FileStorage
,
xid
zodb
.
Xid
,
expect
objState
)
{
t
.
Helper
()
buf
,
tid
,
err
:=
fs
.
Load
(
context
.
Background
(),
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
)
}
switch
{
case
buf
==
nil
:
t
.
Errorf
(
"load %v: returned buf = nil"
,
xid
)
// deleted obj - it should load with "no data
if
expect
.
data
==
nil
{
errOk
:=
&
zodb
.
ErrXidMissing
{
Xid
:
xid
}
e
,
ok
:=
err
.
(
*
zodb
.
ErrXidMissing
)
if
!
(
ok
&&
*
e
==
*
errOk
)
{
t
.
Errorf
(
"load %v: returned err unexpected: %v ; want: %v"
,
xid
,
err
,
errOk
)
}
if
tid
!=
0
{
t
.
Errorf
(
"load %v: returned tid unexpected: %v ; want: %v"
,
xid
,
tid
,
expect
.
tid
)
}
if
buf
!=
nil
{
t
.
Errorf
(
"load %v: returned buf != nil"
,
xid
)
}
// regular load
}
else
{
if
err
!=
nil
{
t
.
Errorf
(
"load %v: returned err unexpected: %v ; want: nil"
,
xid
,
err
)
}
case
!
reflect
.
DeepEqual
(
buf
.
Data
,
expect
.
data
)
:
// NOTE reflect to catch nil != ""
t
.
Errorf
(
"load %v: different data:
\n
have: %q
\n
want: %q"
,
xid
,
buf
.
Data
,
expect
.
data
)
if
tid
!=
expect
.
tid
{
t
.
Errorf
(
"load %v: returned tid unexpected: %v ; want: %v"
,
xid
,
tid
,
expect
.
tid
)
}
switch
{
case
buf
==
nil
:
t
.
Errorf
(
"load %v: returned buf = nil"
,
xid
)
case
!
reflect
.
DeepEqual
(
buf
.
Data
,
expect
.
data
)
:
// NOTE reflect to catch nil != ""
t
.
Errorf
(
"load %v: different data:
\n
have: %q
\n
want: %q"
,
xid
,
buf
.
Data
,
expect
.
data
)
}
}
}
...
...
@@ -106,7 +129,7 @@ func TestLoad(t *testing.T) {
// current knowledge of what was "before" for an oid as we scan over
// data base entries
before
:=
map
[
zodb
.
Oid
]
o
idLoadedOk
{}
before
:=
map
[
zodb
.
Oid
]
o
bjState
{}
for
_
,
dbe
:=
range
_1fs_dbEntryv
{
for
_
,
txe
:=
range
dbe
.
Entryv
{
...
...
@@ -115,12 +138,10 @@ func TestLoad(t *testing.T) {
// XXX check Load finds data at correct .Pos / etc ?
// loadSerial
// TODO also test for getting error when not found
xid
:=
zodb
.
Xid
{
zodb
.
XTid
{
txh
.
Tid
,
false
},
txh
.
Oid
}
checkLoad
(
t
,
fs
,
xid
,
o
idLoadedOk
{
txh
.
Tid
,
txe
.
Data
()})
checkLoad
(
t
,
fs
,
xid
,
o
bjState
{
txh
.
Tid
,
txe
.
Data
()})
// loadBefore
// TODO also test for getting error when not found
xid
=
zodb
.
Xid
{
zodb
.
XTid
{
txh
.
Tid
,
true
},
txh
.
Oid
}
expect
,
ok
:=
before
[
txh
.
Oid
]
if
ok
{
...
...
@@ -129,9 +150,9 @@ func TestLoad(t *testing.T) {
// loadBefore to get current record
xid
.
Tid
+=
1
checkLoad
(
t
,
fs
,
xid
,
o
idLoadedOk
{
txh
.
Tid
,
txe
.
Data
()})
checkLoad
(
t
,
fs
,
xid
,
o
bjState
{
txh
.
Tid
,
txe
.
Data
()})
before
[
txh
.
Oid
]
=
o
idLoadedOk
{
txh
.
Tid
,
txe
.
Data
()}
before
[
txh
.
Oid
]
=
o
bjState
{
txh
.
Tid
,
txe
.
Data
()}
}
}
...
...
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