aboutsummaryrefslogtreecommitdiff
path: root/repo_test.go
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2021-08-24 18:31:13 +0200
committern-peugnet <n.peugnet@free.fr>2021-08-24 18:40:05 +0200
commitdf6d5f7e24a290718adf8f068649c3bc61f5eb4d (patch)
treeddc31a133a8e82b0529264962fd75d6515b1ab4e /repo_test.go
parentb070eae35c1e7a4996b90208153d01f2be08d588 (diff)
downloaddna-backup-df6d5f7e24a290718adf8f068649c3bc61f5eb4d.tar.gz
dna-backup-df6d5f7e24a290718adf8f068649c3bc61f5eb4d.zip
refactor: extract chunk.og & add Reader getter
Diffstat (limited to 'repo_test.go')
-rw-r--r--repo_test.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/repo_test.go b/repo_test.go
index bde2a63..d25ab8a 100644
--- a/repo_test.go
+++ b/repo_test.go
@@ -98,7 +98,7 @@ func TestLoadChunks(t *testing.T) {
resultDir := prepareResult()
dataDir := path.Join("test", "data")
resultVersion := path.Join(resultDir, "00000")
- resultChunks := path.Join(resultVersion, "chunks")
+ resultChunks := path.Join(resultVersion, chunksName)
os.MkdirAll(resultChunks, 0775)
chunks1 := make(chan []byte, 16)
chunks2 := make(chan []byte, 16)
@@ -125,7 +125,7 @@ func TestLoadChunks(t *testing.T) {
func TestStoreLoadFiles(t *testing.T) {
resultDir := prepareResult()
dataDir := path.Join("test", "data")
- resultFiles := path.Join(resultDir, "files")
+ resultFiles := path.Join(resultDir, filesName)
files1 := listFiles(dataDir)
storeFiles(resultFiles, files1)
files2 := loadFiles(resultFiles)
@@ -143,7 +143,7 @@ func TestBsdiff(t *testing.T) {
dataDir := path.Join("test", "data")
addedFile := path.Join(dataDir, "logs.2", "slogTest.log")
resultVersion := path.Join(resultDir, "00000")
- resultChunks := path.Join(resultVersion, "chunks")
+ resultChunks := path.Join(resultVersion, chunksName)
os.MkdirAll(resultChunks, 0775)
chunks := make(chan []byte, 16)
files := listFiles(dataDir)
@@ -163,7 +163,12 @@ func TestBsdiff(t *testing.T) {
hashes := hashChunks(oldChunks)
recipe := repo.matchChunks(newChunks, hashes)
buff := new(bytes.Buffer)
- bsdiff.Reader(recipe[2], recipe[0], buff)
+ r2, _ := recipe[2].Reader(repo.path)
+ r0, _ := recipe[0].Reader(repo.path)
+ bsdiff.Reader(r2, r0, buff)
+ if len(buff.Bytes()) < 500 {
+ t.Errorf("Bsdiff of chunk is too small: %d", len(buff.Bytes()))
+ }
if len(buff.Bytes()) >= chunkSize {
t.Errorf("Bsdiff of chunk is too large: %d", len(buff.Bytes()))
}