From df6d5f7e24a290718adf8f068649c3bc61f5eb4d Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Tue, 24 Aug 2021 18:31:13 +0200 Subject: refactor: extract chunk.og & add Reader getter --- repo_test.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'repo_test.go') 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())) } -- cgit v1.2.3