Commit 02891b74 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent fdda65cd
......@@ -28,6 +28,7 @@ package zdata
import (
"context"
"fmt"
"reflect"
"sort"
"strings"
"testing"
......@@ -98,7 +99,7 @@ func TestΔFtail(t_ *testing.T) {
}
// data built via applying changes from testv
vδf := []ΔFile{} // (rev↑, {}blk) XXX +.Size?
vδf := []*ΔFile{} // (rev↑, {}blk) XXX +.Size?
blkTab := map[int64]string{} // #blk -> ZBlk<oid>
dataTab := map[string]string{} // ZBlk<oid> -> data
Zinblk := map[string]setI64{} // ZBlk<oid> -> which #blk refer to it
......@@ -111,7 +112,7 @@ func TestΔFtail(t_ *testing.T) {
for i, test := range testv {
δf := setI64{}
δblk := setI64{}
// rebuild blkTab/Zinblk
for blk, zblk := range test.δblkTab {
......@@ -132,9 +133,9 @@ func TestΔFtail(t_ *testing.T) {
inblk.Add(blk)
}
// update δf due to change in blkTab
// update δblk due to change in blkTab
if zblk != zprev {
δf.Add(blk)
δblk.Add(blk)
}
}
......@@ -147,29 +148,56 @@ func TestΔFtail(t_ *testing.T) {
data = fmt.Sprintf("%s%d", data[:1], i) // e.g. a4
dataTab[zblk] = data
// update δf due to change in ZBlk data
// update δblk due to change in ZBlk data
for blk := range Zinblk[zblk] {
δf.Add(blk)
δblk.Add(blk)
}
}
vδf = append(vδf, ΔFile{
Rev: zodb.InvalidTid, // XXX will be set after treegen commit
Blocks: δf,
Size: false/*XXX*/,
})
if len(δblk) == 0 {
t.Fatal("BUG: prepared δblk = ø")
}
δfok := &ΔFile{
Rev: zodb.InvalidTid, // will be set after treegen commit
Blocks: δblk,
Size: false/*XXX*/,
}
// commit updated blkTab + dataTab
tdTxt := fmt.Sprintf("t%s D%s", xbtreetest.KVTxt(blkTab), dataTabTxt(dataTab))
commit := t.CommitTree(tdTxt)
δfok.Rev = commit.At
vδf = append(vδf, δfok)
fmt.Printf("@%s δT: %v δD: %s\n", commit.At, test.δblkTab, test.δdataTab)
fmt.Printf("@%s %s\n", commit.At, commit.Tree)
// update δftail
δF, err := δftail.Update(commit.ΔZ); X(err)
// XXX assert
_ = δF
// assert δF points to the file
if δF.Rev != δfok.Rev {
t.Errorf("wrong δF.Rev: have %s ; want %s", δF.Rev, δfok.Rev)
}
δfiles := setOid{}
for δfile := range δF.ByFile {
δfiles.Add(δfile)
}
δfilesOK := setOid{}; δfilesOK.Add(zfile.POid())
if !δfiles.Equal(δfilesOK) {
t.Errorf("wrong δF.ByFile:\nhave keys: %s\nwant keys: %s", δfiles, δfilesOK)
continue
}
// verify δf
δf := δF.ByFile[zfile.POid()]
if !reflect.DeepEqual(δf, δfok) {
t.Errorf("wrong δf:\nhave: %v\nwant: %v", δf, δfok)
}
// XXX verify SliceByFileRev + LastBlkRev
}
}
......
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