Commit b95933e0 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 482dd563
...@@ -22,17 +22,53 @@ package btree ...@@ -22,17 +22,53 @@ package btree
//go:generate ./py/gen-testdata //go:generate ./py/gen-testdata
import ( import (
"context"
"testing" "testing"
"lab.nexedi.com/kirr/neo/go/transaction"
"lab.nexedi.com/kirr/neo/go/zodb"
_ "lab.nexedi.com/kirr/neo/go/zodb/wks"
) )
// kv is one (key, value) pair.
type kv struct { type kv struct {
key int64 key KEY
value interface{} value interface{}
} }
// testEntry is information about 1 Bucket or BTree (XXX) object.
type testEntry struct { type testEntry struct {
oid zodb.Oid oid zodb.Oid
itemv []kv itemv []kv
} }
// TODO func TestBucket(t *testing.T) {
ctx := context.Background()
stor, err := zodb.OpenStorage(ctx, "testdata/1.fs", &zodb.OpenOptions{ReadOnly: true})
if err != nil {
t.Fatal(err)
}
db := zodb.NewDB(stor)
txn, ctx := transaction.New(ctx)
defer txn.Abort()
conn, err := db.Open(ctx)
if err != nil {
t.Fatal(err)
}
for _, tt := range _1fs_testEntry {
xobj, err := conn.Get(ctx, tt.oid)
if err != nil {
t.Fatal(err)
}
obj, ok := xobj.(*Bucket)
if !ok {
t.Fatalf("%s: got %T; want Bucket", tt.oid, xobj)
}
_ = obj
}
}
...@@ -45,7 +45,7 @@ def main(): ...@@ -45,7 +45,7 @@ def main():
print >>f, v print >>f, v
emit("// Code generated by %s; DO NOT EDIT." % __file__) emit("// Code generated by %s; DO NOT EDIT." % __file__)
emit("package btree\n") emit("package btree\n")
emit("import \"lab.nexedi.com/kirr/neo/go/zodb\"\n") #emit("import \"lab.nexedi.com/kirr/neo/go/zodb\"\n")
emit("\nvar _1fs_testEntry = [...]testEntry{") emit("\nvar _1fs_testEntry = [...]testEntry{")
for b in (b0, b1, b2): for b in (b0, b1, b2):
...@@ -54,7 +54,7 @@ def main(): ...@@ -54,7 +54,7 @@ def main():
if isinstance(v, str): if isinstance(v, str):
v = qq(v) v = qq(v)
s += "{%s, %s}, " % (k, v) s += "{%s, %s}, " % (k, v)
s += "}," s += "}},"
emit("\t"+s) emit("\t"+s)
emit("}") emit("}")
......
// Code generated by ./py/gen-testdata; DO NOT EDIT. // Code generated by ./py/gen-testdata; DO NOT EDIT.
package btree package btree
import "lab.nexedi.com/kirr/neo/go/zodb"
var _1fs_testEntry = [...]testEntry{ var _1fs_testEntry = [...]testEntry{
testEntry{oid: 1, itemv: []kv{}, testEntry{oid: 1, itemv: []kv{}},
testEntry{oid: 2, itemv: []kv{{10, 17}, }, testEntry{oid: 2, itemv: []kv{{10, 17}, }},
testEntry{oid: 3, itemv: []kv{{15, 1}, {23, "hello"}, }, testEntry{oid: 3, itemv: []kv{{15, 1}, {23, "hello"}, }},
} }
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