Commit 8fafde00 authored by Kirill Smelkov's avatar Kirill Smelkov

go/zodb/zeo: Factor-out verifying empty database into xtesting.DrvTestEmptyDB

And use it to verify other storages.
parent 762073ee
......@@ -136,6 +136,17 @@ func ZPyCommitRaw(zurl string, at zodb.Tid, objv ...ZRawObject) (_ zodb.Tid, err
// ---- tests for storage drivers ----
// DrvTestEmptyDB verifies that zdrv works correctly on empty database.
func DrvTestEmptyDB(t *testing.T, zdrv zodb.IStorageDriver) {
X := FatalIf(t)
ctx := context.Background()
head, err := zdrv.Sync(ctx); X(err)
headOk := zodb.Tid(0)
if head != headOk {
t.Errorf("head=%s ; expected %s", head, headOk)
}
}
// state of an object in the database for some particular revision
type objState struct {
tid zodb.Tid
......
......@@ -72,6 +72,13 @@ func xfsopenopt(t testing.TB, path string, opt *zodb.DriverOptions) (*FileStorag
return fs, at0
}
func TestEmptyDB(t *testing.T) {
fs, _ := xfsopen(t, "testdata/empty.fs")
defer exc.XRun(fs.Close)
xtesting.DrvTestEmptyDB(t, fs)
}
func TestLoad(t *testing.T) {
fs, _ := xfsopen(t, "testdata/1.fs")
defer exc.XRun(fs.Close)
......
......@@ -244,13 +244,7 @@ func TestHandshake(t *testing.T) {
// verify that connection to ZEO server with empty DB works ok.
func TestEmptyDB(t *testing.T) {
withZEO(t, func(t *testing.T, zsrv ZEOSrv, z *zeo) {
X := xtesting.FatalIf(t)
ctx := context.Background()
head, err := z.Sync(ctx); X(err)
headOk := zodb.Tid(0)
if head != headOk {
t.Errorf("head=%s ; expected %s", head, headOk)
}
xtesting.DrvTestEmptyDB(t, z)
})
}
......
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