Commit 9104c87b authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent cd86628f
...@@ -21,8 +21,12 @@ import ( ...@@ -21,8 +21,12 @@ import (
"testing" "testing"
"../../zodb" "../../zodb"
"lab.nexedi.com/kirr/go123/exc"
) )
// XXX -> testDbEntry ?
// one database transaction record // one database transaction record
type dbEntry struct { type dbEntry struct {
Header TxnHeader Header TxnHeader
...@@ -51,6 +55,7 @@ type oidLoadedOk struct { ...@@ -51,6 +55,7 @@ type oidLoadedOk struct {
data []byte data []byte
} }
// checkLoad verifies that fs.Load(xid) returns expected result
func checkLoad(t *testing.T, fs *FileStorage, xid zodb.Xid, expect oidLoadedOk) { func checkLoad(t *testing.T, fs *FileStorage, xid zodb.Xid, expect oidLoadedOk) {
data, tid, err := fs.Load(xid) data, tid, err := fs.Load(xid)
if err != nil { if err != nil {
...@@ -64,12 +69,17 @@ func checkLoad(t *testing.T, fs *FileStorage, xid zodb.Xid, expect oidLoadedOk) ...@@ -64,12 +69,17 @@ func checkLoad(t *testing.T, fs *FileStorage, xid zodb.Xid, expect oidLoadedOk)
} }
} }
func TestLoad(t *testing.T) { func xfsopen(t *testing.T, path string) *FileStorage {
fs, err := Open("testdata/1.fs") fs, err := Open(path)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
//defer xclose(fs) return fs
}
func TestLoad(t *testing.T) {
fs := xfsopen(t, "testdata/1.fs") // TODO open read-only
defer exc.XRun(fs.Close)
// current knowledge of what was "before" for an oid as we scan over // current knowledge of what was "before" for an oid as we scan over
// data base entries // data base entries
...@@ -108,6 +118,11 @@ func TestLoad(t *testing.T) { ...@@ -108,6 +118,11 @@ func TestLoad(t *testing.T) {
xid := zodb.Xid{zodb.XTid{zodb.TidMax, true}, oid} xid := zodb.Xid{zodb.XTid{zodb.TidMax, true}, oid}
checkLoad(t, fs, xid, expect) checkLoad(t, fs, xid, expect)
} }
}
func TestIterate(t *testing.T) {
fs := xfsopen(t, "testdata/1.fs") // TODO open ro
defer exc.XRun(fs.Close)
// check iterating XXX move to separate test ? // check iterating XXX move to separate test ?
// tids we will use for tid{Min,Max} // tids we will use for tid{Min,Max}
......
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