From 129a86b3a6780b7aee5a7469cc5adeaf2ea6c20f Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Fri, 27 Aug 2021 18:38:07 +0200 Subject: add findSimilarChunks method to test sketches Still missing a real test... --- repo_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'repo_test.go') 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) } -- cgit v1.2.3