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
557a3b96
Commit
557a3b96
authored
Jul 07, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
4ca61cd7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
21 deletions
+24
-21
go/internal/xtesting/xtesting.go
go/internal/xtesting/xtesting.go
+16
-8
go/zodb/storage/fs1/filestorage_test.go
go/zodb/storage/fs1/filestorage_test.go
+3
-0
go/zodb/storage/zeo/zeo_test.go
go/zodb/storage/zeo/zeo_test.go
+5
-13
No files found.
go/internal/xtesting/xtesting.go
View file @
557a3b96
...
...
@@ -150,11 +150,11 @@ type Txn struct {
Data
[]
*
zodb
.
DataInfo
}
// LoadDB loads whole content of a ZODB database.
// LoadDB
History
loads whole content of a ZODB database.
//
// it returns full history of all transactions with committed data.
func
LoadDB
(
zurl
string
)
(
_
[]
Txn
,
err
error
)
{
xerr
.
Contextf
(
&
err
,
"load
db
%s"
,
zurl
)
func
LoadDB
History
(
zurl
string
)
(
_
[]
Txn
,
err
error
)
{
xerr
.
Contextf
(
&
err
,
"load
DBHistory
%s"
,
zurl
)
ctx
:=
context
.
Background
()
zstor
,
err
:=
zodb
.
Open
(
ctx
,
zurl
,
&
zodb
.
OpenOptions
{
ReadOnly
:
true
})
if
err
!=
nil
{
...
...
@@ -300,11 +300,7 @@ func DrvTestLoad(t *testing.T, zdrv zodb.IStorageDriver, txnvOk []Txn) {
// DrvTestWatch verifies that storage driver watcher can observe commits done from outside.
func
DrvTestWatch
(
t
*
testing
.
T
,
zurl
string
,
zdrvOpen
zodb
.
DriverOpener
)
{
t
.
Helper
()
X
:=
func
(
err
error
)
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
X
:=
FatalIf
(
t
)
NeedPy
(
t
,
"zodbtools"
)
...
...
@@ -400,6 +396,15 @@ func DrvTestWatch(t *testing.T, zurl string, zdrvOpen zodb.DriverOpener) {
}
// FatalIf(t) returns function f(err), which call t.Fatal if err != nil.
func
FatalIf
(
t
*
testing
.
T
)
func
(
error
)
{
return
func
(
err
error
)
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
}
// b is syntactic sugar for byte literals.
//
...
...
@@ -412,6 +417,9 @@ func b(data string) []byte {
// bcopy makes a clone of byte slice.
func
bcopy
(
data
[]
byte
)
[]
byte
{
if
data
==
nil
{
return
nil
}
d2
:=
make
([]
byte
,
len
(
data
))
copy
(
d2
,
data
)
return
d2
...
...
go/zodb/storage/fs1/filestorage_test.go
View file @
557a3b96
...
...
@@ -76,6 +76,9 @@ func TestLoad(t *testing.T) {
fs
,
_
:=
xfsopen
(
t
,
"testdata/1.fs"
)
defer
exc
.
XRun
(
fs
.
Close
)
// NOTE don't use xtesting.LoadDBHistory here - it is itself tested
// with the assumption that fs1.Load and fs1.Iterate works correctly.
// Use what testdata generator gave use with what to expect.
txnv
:=
[]
xtesting
.
Txn
{}
for
_
,
dbe
:=
range
_1fs_dbEntryv
{
txn
:=
xtesting
.
Txn
{
Header
:
&
zodb
.
TxnInfo
{
...
...
go/zodb/storage/zeo/zeo_test.go
View file @
557a3b96
...
...
@@ -163,7 +163,7 @@ func withZEOSrv(t *testing.T, f func(t *testing.T, zsrv ZEOSrv), optv ...tOption
// withFS1 runs f under environment with new FileStorage database.
withFS1
:=
func
(
t
*
testing
.
T
,
f
func
(
fs1path
string
))
{
t
.
Helper
()
X
:=
mk
FatalIf
(
t
)
X
:=
xtesting
.
FatalIf
(
t
)
work
:=
xtempdir
(
t
)
defer
os
.
RemoveAll
(
work
)
fs1path
:=
work
+
"/1.fs"
...
...
@@ -186,7 +186,7 @@ func withZEOSrv(t *testing.T, f func(t *testing.T, zsrv ZEOSrv), optv ...tOption
}
xtesting
.
NeedPy
(
t
,
needpy
...
)
withFS1
(
t
,
func
(
fs1path
string
)
{
X
:=
mk
FatalIf
(
t
)
X
:=
xtesting
.
FatalIf
(
t
)
zpy
,
err
:=
StartZEOPySrv
(
fs1path
,
ZEOPyOptions
{
msgpack
:
msgpack
});
X
(
err
)
defer
func
()
{
...
...
@@ -206,7 +206,7 @@ func withZEO(t *testing.T, f func(t *testing.T, zdrv *zeo), optv ...tOptions) {
t
.
Helper
()
withZEOSrv
(
t
,
func
(
t
*
testing
.
T
,
zsrv
ZEOSrv
)
{
t
.
Helper
()
X
:=
mk
FatalIf
(
t
)
X
:=
xtesting
.
FatalIf
(
t
)
zdrv
,
_
,
err
:=
zeoOpen
(
zsrv
.
Addr
(),
&
zodb
.
DriverOptions
{
ReadOnly
:
true
});
X
(
err
)
defer
func
()
{
err
:=
zdrv
.
Close
();
X
(
err
)
...
...
@@ -217,7 +217,7 @@ func withZEO(t *testing.T, f func(t *testing.T, zdrv *zeo), optv ...tOptions) {
}
func
TestHandshake
(
t
*
testing
.
T
)
{
X
:=
mk
FatalIf
(
t
)
X
:=
xtesting
.
FatalIf
(
t
)
withZEOSrv
(
t
,
func
(
t
*
testing
.
T
,
zsrv
ZEOSrv
)
{
ctx
:=
context
.
Background
()
net
:=
xnet
.
NetPlain
(
"unix"
)
...
...
@@ -237,7 +237,7 @@ func TestLoad(t *testing.T) {
X
:=
exc
.
Raiseif
data
:=
"../fs1/testdata/1.fs"
txnvOk
,
err
:=
xtesting
.
LoadDB
(
data
);
X
(
err
)
txnvOk
,
err
:=
xtesting
.
LoadDB
History
(
data
);
X
(
err
)
withZEO
(
t
,
func
(
t
*
testing
.
T
,
z
*
zeo
)
{
xtesting
.
DrvTestLoad
(
t
,
z
,
txnvOk
)
...
...
@@ -276,11 +276,3 @@ func xtempdir(t *testing.T) string {
}
return
tmpd
}
func
mkFatalIf
(
t
*
testing
.
T
)
func
(
error
)
{
return
func
(
err
error
)
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
}
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