Commit d8004baf authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent d4e577aa
......@@ -87,17 +87,17 @@ func NeedPy(t testing.TB, modules ...string) {
return
}
// ZObject represents object state to be committed.
type ZObject struct {
// ZRawObject represents raw ZODB object state.
type ZRawObject struct {
Oid zodb.Oid
Data string // raw serialized zodb data
}
// ZPyCommit commits new transaction into database @ zurl with data specified by objv.
// ZPyCommitRaw commits new transaction into database @ zurl with raw data specified by objv.
//
// The commit is performed via zodbtools/py.
func ZPyCommit(zurl string, at zodb.Tid, objv ...ZObject) (_ zodb.Tid, err error) {
defer xerr.Contextf(&err, "%s: zcommit @%s", zurl, at)
func ZPyCommitRaw(zurl string, at zodb.Tid, objv ...ZRawObject) (_ zodb.Tid, err error) {
defer xerr.Contextf(&err, "%s: zpycommit @%s", zurl, at)
// prepare text input for `zodb commit`
zin := &bytes.Buffer{}
......
......@@ -34,14 +34,14 @@ func init() {
}
func ZPyCommit(zurl string, at zodb.Tid, objv ...zodb.IPersistent) (zodb.Tid, error) {
var zobjv []xtesting.ZObject // raw zodb objects data to commit
var rawobjv []xtesting.ZRawObject // raw zodb objects data to commit
for _, obj := range objv {
zobj := xtesting.ZObject{
rawobj := xtesting.ZRawObject{
Oid: obj.POid(),
Data: string(zodb.PSerialize(obj).XData()),
}
zobjv = append(zobjv, zobj)
rawobjv = append(rawobjv, rawobj)
}
return xtesting.ZPyCommit(zurl, at, zobjv...)
return xtesting.ZPyCommitRaw(zurl, at, rawobjv...)
}
......@@ -358,15 +358,15 @@ func TestWatch(t *testing.T) {
workdir := xworkdir(t)
tfs := workdir + "/t.fs"
// xcommit commits new transaction into tfs with data specified by objv.
xcommit := func(at zodb.Tid, objv ...xtesting.ZObject) zodb.Tid {
// xcommit commits new transaction into tfs with raw data specified by objv.
xcommit := func(at zodb.Tid, objv ...xtesting.ZRawObject) zodb.Tid {
t.Helper()
tid, err := xtesting.ZPyCommit(tfs, at, objv...); X(err)
tid, err := xtesting.ZPyCommitRaw(tfs, at, objv...); X(err)
return tid
}
// force tfs creation & open tfs at go side
at := xcommit(0, xtesting.ZObject{0, "data0"})
at := xcommit(0, xtesting.ZRawObject{0, "data0"})
watchq := make(chan zodb.CommitEvent)
fs := xfsopenopt(t, tfs, &zodb.DriverOptions{ReadOnly: true, Watchq: watchq})
......@@ -407,8 +407,8 @@ func TestWatch(t *testing.T) {
data0 := fmt.Sprintf("data0.%d", i)
datai := fmt.Sprintf("data%d", i)
at = xcommit(at,
xtesting.ZObject{0, data0},
xtesting.ZObject{i, datai})
xtesting.ZRawObject{0, data0},
xtesting.ZRawObject{i, datai})
// TODO also test for watcher errors
e := <-watchq
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment