Commit fa838dba authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent c895576f
...@@ -193,11 +193,11 @@ func XGetTree(db *zodb.DB, at zodb.Tid, root zodb.Oid) map[Key]string { ...@@ -193,11 +193,11 @@ func XGetTree(db *zodb.DB, at zodb.Tid, root zodb.Oid) map[Key]string {
} }
// verifyΔBTail verifies how ΔBTail handles ZODB update for a tree with changes in between at1->at2. // xverifyΔBTail verifies how ΔBTail handles ZODB update for a tree with changes in between at1->at2.
// //
// it is known that @at1 and @at2 the tree has kv1 and kv2 values correspondingly. // it is known that @at1 and @at2 the tree has kv1 and kv2 values correspondingly.
// it is known that for at1->at2 ZODB-level change is δZ. // it is known that for at1->at2 ZODB-level change is δZ.
func verifyΔBTail(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, at1, at2 zodb.Tid, kv1, kv2 map[Key]string, δZ *zodb.EventCommit) { func xverifyΔBTail(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, at1, at2 zodb.Tid, kv1, kv2 map[Key]string, δZ *zodb.EventCommit) {
// verify transition at1->at2 for all initial states of tracked {keys} from kv1 // verify transition at1->at2 for all initial states of tracked {keys} from kv1
keyv1 := []Key{} keyv1 := []Key{}
for k1 := range kv1 { for k1 := range kv1 {
...@@ -212,13 +212,13 @@ func verifyΔBTail(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, at1, at2 zodb.T ...@@ -212,13 +212,13 @@ func verifyΔBTail(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, at1, at2 zodb.T
keys[i] = keyv1[i] keys[i] = keyv1[i]
} }
verifyΔBTail1(t, db, treeRoot, at1,at2, kv1,kv2, δZ, keys) xverifyΔBTail1(t, db, treeRoot, at1,at2, kv1,kv2, δZ, keys)
} }
} }
// verifyΔBTail1 verifies how ΔBTail handles ZODB update at1->at2 from initial // xverifyΔBTail1 verifies how ΔBTail handles ZODB update at1->at2 from initial
// tracked state defined by initialTrackedKeys. // tracked state defined by initialTrackedKeys.
func verifyΔBTail1(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, at1,at2 zodb.Tid, kv1,kv2 map[Key]string, δZ *zodb.EventCommit, initialTrackedKeys []Key) { func xverifyΔBTail1(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, at1,at2 zodb.Tid, kv1,kv2 map[Key]string, δZ *zodb.EventCommit, initialTrackedKeys []Key) {
X := exc.Raiseif X := exc.Raiseif
fmt.Println("verify1", initialTrackedKeys) fmt.Println("verify1", initialTrackedKeys)
...@@ -244,12 +244,19 @@ func verifyΔBTail1(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, at1,at2 zodb.T ...@@ -244,12 +244,19 @@ func verifyΔBTail1(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, at1,at2 zodb.T
// δbtail <- δZ // δbtail <- δZ
δB := δbtail.Update(δZ) δB := δbtail.Update(δZ)
// XXX check δB // XXX assert δB.keys == treeRoot
_ = δB // δT = δB[treeRoot]
// all keys from d12/tracked are present in δT
//for (k,v) in d12: //for (k,v) in d12:
// if k in initialTrackedKeys: // if k in initialTrackedKeys:
// assert k in δB // assert k in δT
// assert δT[k] == v
// else:
// if k in δT:
// assert δT[k] == v
//
// XXX all keys from δT are present in d12
} }
func TestΔBTail(t *testing.T) { func TestΔBTail(t *testing.T) {
...@@ -289,7 +296,7 @@ func TestΔBTail(t *testing.T) { ...@@ -289,7 +296,7 @@ func TestΔBTail(t *testing.T) {
err := db.Close(); X(err) err := db.Close(); X(err)
}() }()
// XCommitTree calls tg.Commit and returns δZ corresponding to made transaction. // XCommitTree calls tg.Commit and returns δZ corresponding to committed transaction.
XCommitTree := func(tree string) *zodb.EventCommit { XCommitTree := func(tree string) *zodb.EventCommit {
defer exc.Contextf("commit %s", tree) defer exc.Contextf("commit %s", tree)
...@@ -345,10 +352,9 @@ func TestΔBTail(t *testing.T) { ...@@ -345,10 +352,9 @@ func TestΔBTail(t *testing.T) {
for _, tree := range testv { for _, tree := range testv {
δZ := XCommitTree(tree) // tree2 δZ := XCommitTree(tree) // tree2
at2 := δZ.Tid at2 := δZ.Tid
//at2, err := tg.Commit(tree); X(err) // tree2
kv2 := XGetTree(db, at2, tg.treeRoot) kv2 := XGetTree(db, at2, tg.treeRoot)
verifyΔBTail(t, db, tg.treeRoot, at1,at2, kv1,kv2, δZ) xverifyΔBTail(t, db, tg.treeRoot, at1,at2, kv1,kv2, δZ)
at1 = at2 at1 = at2
kv1 = kv2 kv1 = kv2
......
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