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
3356c294
Commit
3356c294
authored
Mar 17, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
a1ceb162
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
24 deletions
+49
-24
go/zodb/storage/demo/demo_test.go
go/zodb/storage/demo/demo_test.go
+49
-24
No files found.
go/zodb/storage/demo/demo_test.go
View file @
3356c294
...
...
@@ -169,46 +169,71 @@ func TestWatch(t *testing.T) {
})
}
// withDemoBaseMutated tests f with demo: client connected to Storage and base
// just mutated with new commit.
func
withDemoBaseMutated
(
t
*
testing
.
T
,
f
func
(
t
*
testing
.
T
,
ddrv
*
Storage
))
{
withDemo
(
t
,
func
(
t
*
testing
.
T
,
ddat
*
DemoData
,
ddrv
*
Storage
)
{
X
:=
xtesting
.
FatalIf
(
t
)
/* XXX kill?
head, err := ddrv.Sync(context.Background())
if !(head == 0 && err == nil) {
t.Fatalf("sync0: head=%s err=%s", head, err)
}
*/
// MutateBase mutates ddat.base with new commit.
func
(
ddat
*
DemoData
)
MutateBase
()
error
{
_
,
err
=
xtesting
.
ZPyCommitRaw
(
ddat
.
base
,
0
,
xtesting
.
ZRawObject
{
Oid
:
1
,
Data
:
[]
byte
(
"ZZZ"
),
});
X
(
err
)
f
(
t
,
ddrv
)
})
}
// TestSync_vs_BaseMutate verifies Sync wrt base mutation.
func
TestSync_vs_BaseMutate
(
t
*
testing
.
T
)
{
withDemo
BaseMutated
(
t
,
func
(
t
*
testing
.
T
,
ddrv
*
Storage
)
{
withDemo
(
t
,
func
(
t
*
testing
.
T
,
ddat
*
DemoData
,
ddrv
*
Storage
)
{
X
:=
xtesting
.
FatalIf
(
t
)
head
,
err
:=
ddrv
.
Sync
(
context
.
Background
())
// XXX verify err
if
!
(
head
==
0
&&
err
==
nil
)
{
t
.
Fatalf
(
"sync0: head=%s err=%s"
,
head
,
err
)
}
err
=
ddat
.
MutateBase
();
X
(
err
)
head
,
err
:=
ddrv
.
Sync
(
context
.
Background
())
errOk
:=
&
zodb
.
OpError
{
URL
:
ddrv
.
URL
(),
Op
:
"sync"
,
Err
:
...
}
if
!
reflect
.
DeepEqual
(
err
,
errOk
)
{
t
.
Fatalf
(
"after base mutate: sync: unexpected error:
\n
have: %s
\n
want: %s"
,
err
,
errOk
)
}
})
}
// TestWatchLoad_vs_BaseMutate verifies Watch and Load wrt base mutation.
func
TestLoad_vs_BaseMutate
(
t
*
testing
.
T
)
{
withDemo
BaseMutated
(
t
,
func
(
t
*
testing
.
T
,
ddrv
*
Storage
)
{
func
Test
Watch
Load_vs_BaseMutate
(
t
*
testing
.
T
)
{
withDemo
Data
(
t
,
func
(
t
*
testing
.
T
,
ddat
*
DemoData
)
{
X
:=
xtesting
.
FatalIf
(
t
)
// XXX first wait for error from watchq
data
,
serial
,
err
:=
ddrv
.
Load
(
context
.
Background
(),
...
)
// XXX verify err
watchq
:=
make
(
chan
zodb
.
Event
)
ddrv
,
at0
,
err
=
demoOpen
(
ddat
.
URL
(),
&
zodb
.
DriverOptions
{
ReadOnly
:
true
,
Watchq
:
watchq
,
});
X
(
err
)
err
=
ddat
.
MutateBase
();
X
(
err
)
// first wait for error from watchq
event
:=
<-
watchq
evErr
,
ok
:=
event
.
(
*
zodb
.
EventError
)
if
!
ok
{
t
.
Fatalf
(
"unexpected event: %T"
,
event
)
}
evErrOk
:=
&
zodb
.
EventError
{
Err
:
...
}
// XXX
if
!
reflect
.
DeepEqual
(
evErr
,
evErrOk
)
{
t
.
Fatalf
(
"after base mutate: unexpected event:
\n
have: %s
\n
want: %s"
,
evErr
,
evErrOk
)
}
// now make sure Load fails with "base mutated" error
xid
:=
zodb
.
Xid
{
Oid
:
1
,
At
:
zodb
.
MaxTid
}
data
,
serial
,
err
:=
ddrv
.
Load
(
context
.
Background
(),
xid
)
errOk
:=
&
zodb
.
OpError
{
URL
:
ddrv
.
URL
(),
Op
:
"load"
,
Args
:
xid
,
Err
:
...
}
if
!
reflect
.
DeepEqual
(
err
,
errOk
)
{
t
.
Fatalf
(
"after base mutate: load: unexpected error:
\n
have: %s
\n
want: %s"
,
err
,
errOk
)
}
if
!
(
data
==
nil
&&
serial
==
0
)
{
t
.
Fatalf
(
"after base mutate: load: unexpected data=%v serial=%v"
,
data
,
serial
)
}
})
}
...
...
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