diff options
Diffstat (limited to 'repo_test.go')
-rw-r--r-- | repo_test.go | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/repo_test.go b/repo_test.go index 27cdebf..956bd84 100644 --- a/repo_test.go +++ b/repo_test.go @@ -7,7 +7,7 @@ import ( "testing" ) -func preparResult() { +func prepareResult() { result := path.Join("test", "result") os.RemoveAll(result) os.MkdirAll(result, 0775) @@ -76,3 +76,31 @@ func TestReadFiles3(t *testing.T) { } chunkCompare(t, dataDir, files, chunkCount) } + +func TestLoadChunks(t *testing.T) { + prepareResult() + dataDir := path.Join("test", "data") + resultDir := path.Join("test", "result") + files1 := make(chan File) + files2 := make(chan File) + chunks1 := make(chan []byte) + chunks2 := make(chan []byte) + chunks3 := make(chan []byte) + go ListFiles(dataDir, files1) + go ListFiles(dataDir, files2) + go ReadFiles(files1, chunks1) + go ReadFiles(files2, chunks2) + StoreChunks(resultDir, chunks1) + go LoadChunks(resultDir, chunks3) + + i := 0 + for c2 := range chunks2 { + c3 := <-chunks3 + if bytes.Compare(c2, c3) != 0 { + t.Errorf("Chunk %d does not match file content", i) + t.Log(c2) + t.Log(c3) + } + i++ + } +} |