Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
02891b74
Commit
02891b74
authored
Jul 08, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
fdda65cd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
13 deletions
+41
-13
wcfs/internal/zdata/δftail_test.go
wcfs/internal/zdata/δftail_test.go
+41
-13
No files found.
wcfs/internal/zdata/δftail_test.go
View file @
02891b74
...
...
@@ -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:
\n
have keys: %s
\n
want keys: %s"
,
δfiles
,
δfilesOK
)
continue
}
// verify δf
δf
:=
δF
.
ByFile
[
zfile
.
POid
()]
if
!
reflect
.
DeepEqual
(
δf
,
δfok
)
{
t
.
Errorf
(
"wrong δf:
\n
have: %v
\n
want: %v"
,
δf
,
δfok
)
}
// XXX verify SliceByFileRev + LastBlkRev
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment