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
998fad3e
Commit
998fad3e
authored
Jul 06, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
0c47f04e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
2 deletions
+62
-2
go/zodb/storage/zeo/zeo_test.go
go/zodb/storage/zeo/zeo_test.go
+62
-2
No files found.
go/zodb/storage/zeo/zeo_test.go
View file @
998fad3e
...
...
@@ -144,6 +144,7 @@ func (z *ZEOPySrv) Encoding() byte {
// ----------------
/*
// withZEOPySrv spawns new ZEO/py server and runs f in that environment.
func withZEOPySrv(t *testing.T, opt ZEOPyOptions, f func(zpy *ZEOPySrv)) {
X := mkFatalIf(t)
...
...
@@ -161,15 +162,61 @@ func withZEOPySrv(t *testing.T, opt ZEOPyOptions, f func(zpy *ZEOPySrv)) {
f(zpy)
}
*/
// tOptions represents options for testing.
type
tOptions
struct
{
Preload
string
// preload database from this location
}
// withZEOSrv tests f with all kind of ZEO servers.
func
withZEOSrv
(
t
*
testing
.
T
,
f
func
(
t
*
testing
.
T
,
zsrv
ZEOSrv
),
optv
...
tOptions
)
{
t
.
Helper
()
opt
:=
tOptions
{}
if
len
(
optv
)
>
1
{
panic
(
"multiple tOptions not allowed"
)
}
if
len
(
optv
)
==
1
{
opt
=
optv
[
0
]
}
// withFS1 runs f under environment with new FileStorage database.
withFS1
:=
func
(
t
*
testing
.
T
,
f
func
(
fs1path
string
))
{
X
:=
mkFatalIf
(
t
)
work
:=
xtempdir
(
t
)
defer
os
.
RemoveAll
(
work
)
fs1path
:=
work
+
"/1.fs"
if
opt
.
Preload
!=
""
{
data
,
err
:=
ioutil
.
ReadFile
(
opt
.
Preload
);
X
(
err
)
err
=
ioutil
.
WriteFile
(
fs1path
,
data
,
0644
);
X
(
err
)
}
f
(
fs1path
)
}
// withZEOSrv runs f under all kind of ZEO servers.
func
withZEOSrv
(
t
*
testing
.
T
,
f
func
(
t
*
testing
.
T
,
zsrv
ZEOSrv
))
{
for
_
,
msgpack
:=
range
[]
bool
{
false
,
true
}
{
// ZEO/py
t
.
Run
(
fmt
.
Sprintf
(
"py/msgpack=%v"
,
msgpack
),
func
(
t
*
testing
.
T
)
{
needZEOpy
(
t
)
withFS1
(
t
,
func
(
fs1path
string
)
{
X
:=
mkFatalIf
(
t
)
zpy
,
err
:=
StartZEOPySrv
(
fs1path
,
ZEOPyOptions
{
msgpack
:
msgpack
});
X
(
err
)
defer
func
()
{
err
:=
zpy
.
Close
();
X
(
err
)
}()
f
(
t
,
zpy
)
})
/*
withZEOPySrv(t, ZEOPyOptions{msgpack: msgpack}, func(zpy *ZEOPySrv) {
f(t, zpy)
})
*/
})
// TODO ZEO/go
...
...
@@ -218,6 +265,19 @@ func TestLoad(t *testing.T) {
}()
xtesting
.
DrvTestLoad
(
t
,
z
,
txnvOk
)
withZEOSrv
(
t
,
func
(
t
*
testing
.
T
,
zsrv
ZEOSrv
)
{
z
,
_
,
err
:=
zeoOpen
(
zpy
.
Addr
(),
&
zodb
.
DriverOptions
{
ReadOnly
:
true
});
X
(
err
)
defer
func
()
{
err
:=
z
.
Close
();
X
(
err
)
}()
xtesting
.
DrvTestLoad
(
t
,
z
,
txnvOk
)
},
tOptions
{
Preload
:
"../fs1/testdata/1.fs"
,
})
}
func
TestWatch
(
t
*
testing
.
T
)
{
...
...
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