From afc30e335fb45910cb441956b239fc0d8f89446f Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Mon, 30 Aug 2021 14:34:55 +0200 Subject: better diff test --- repo_test.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'repo_test.go') diff --git a/repo_test.go b/repo_test.go index 3a4af68..cbb54df 100644 --- a/repo_test.go +++ b/repo_test.go @@ -187,22 +187,22 @@ func TestBsdiff(t *testing.T) { go concatFiles(files, writer) fingerprints, sketches := hashChunks(oldChunks) recipe := repo.matchStream(reader, fingerprints) - buff := new(bytes.Buffer) - r2 := recipe[2].Reader() - r0 := recipe[0].Reader() - bsdiff.Reader(r2, r0, buff) - log.Println("Diff size:", buff.Len()) - if buff.Len() < 500 { - t.Errorf("Bsdiff of chunk is too small: %d", buff.Len()) - } - if buff.Len() >= chunkSize { - t.Errorf("Bsdiff of chunk is too large: %d", buff.Len()) - } newChunks := extractNewChunks(recipe) log.Println("Checking new chunks:", len(newChunks[0])) for _, chunks := range newChunks { for _, c := range chunks { - log.Println(findSimilarChunk(c, sketches)) + id, exists := findSimilarChunk(c, sketches) + log.Println(id, exists) + if exists { + patch := new(bytes.Buffer) + stored := id.Reader(repo.path) + new := c.Reader() + bsdiff.Reader(stored, new, patch) + log.Println("Patch size:", patch.Len()) + if patch.Len() >= chunkSize/10 { + t.Errorf("Bsdiff of chunk is too large: %d", patch.Len()) + } + } } } } -- cgit v1.2.3