diff options
author | n-peugnet <n.peugnet@free.fr> | 2021-08-30 14:34:55 +0200 |
---|---|---|
committer | n-peugnet <n.peugnet@free.fr> | 2021-08-30 14:34:55 +0200 |
commit | afc30e335fb45910cb441956b239fc0d8f89446f (patch) | |
tree | 6869adbbf007ec7d27a511af7cdd236ac785a44d /repo_test.go | |
parent | ea34c64c5cd6d62af487a0db62bd64a2b467ec25 (diff) | |
download | dna-backup-afc30e335fb45910cb441956b239fc0d8f89446f.tar.gz dna-backup-afc30e335fb45910cb441956b239fc0d8f89446f.zip |
better diff test
Diffstat (limited to 'repo_test.go')
-rw-r--r-- | repo_test.go | 24 |
1 files changed, 12 insertions, 12 deletions
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()) + } + } } } } |