aboutsummaryrefslogtreecommitdiff
path: root/repo_test.go
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2021-08-27 18:38:07 +0200
committern-peugnet <n.peugnet@free.fr>2021-08-27 18:38:16 +0200
commit129a86b3a6780b7aee5a7469cc5adeaf2ea6c20f (patch)
treeab8423f6885c380b2bb4d807313428003d8d5e37 /repo_test.go
parent78251f11c91b2504edfc02b760ef53bd352b856c (diff)
downloaddna-backup-129a86b3a6780b7aee5a7469cc5adeaf2ea6c20f.tar.gz
dna-backup-129a86b3a6780b7aee5a7469cc5adeaf2ea6c20f.zip
add findSimilarChunks method to test sketches
Still missing a real test...
Diffstat (limited to 'repo_test.go')
-rw-r--r--repo_test.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/repo_test.go b/repo_test.go
index 8c07c5b..d9c938d 100644
--- a/repo_test.go
+++ b/repo_test.go
@@ -4,6 +4,7 @@ import (
"bytes"
"io"
"io/ioutil"
+ "log"
"os"
"path"
"testing"
@@ -179,8 +180,8 @@ func TestBsdiff(t *testing.T) {
versions := repo.loadVersions()
go repo.loadChunks(versions, oldChunks)
go concatFiles(files, writer)
- hashes := hashChunks(oldChunks)
- recipe := repo.matchStream(reader, hashes)
+ fingerprints, sketches := hashChunks(oldChunks)
+ recipe := repo.matchStream(reader, fingerprints)
buff := new(bytes.Buffer)
r2, _ := recipe[2].Reader()
r0, _ := recipe[0].Reader()
@@ -191,6 +192,11 @@ func TestBsdiff(t *testing.T) {
if len(buff.Bytes()) >= chunkSize {
t.Errorf("Bsdiff of chunk is too large: %d", len(buff.Bytes()))
}
+ newChunks := extractNewChunks(recipe)
+ log.Println("Checking new chunks:", len(newChunks[0]))
+ for _, c := range newChunks {
+ findSimilarChunks(c, sketches)
+ }
os.Remove(addedFile)
}