diff options
-rw-r--r-- | .github/workflows/build.yml | 1 | ||||
-rw-r--r-- | repo.go | 15 | ||||
-rw-r--r-- | repo_test.go | 9 |
3 files changed, 14 insertions, 11 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4276554..b701a0d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,6 +15,7 @@ jobs: uses: golangci/golangci-lint-action@v2 with: version: v1.29 + args: --issues-exit-code=0 # do not fail ci only-new-issues: true test: runs-on: ubuntu-latest @@ -28,7 +28,6 @@ import ( "bufio" "bytes" "encoding/gob" - "errors" "fmt" "hash" "io" @@ -72,9 +71,9 @@ type File struct { func NewRepo(path string) *Repo { err := os.MkdirAll(path, 0775) - // if err != nil { - // log.Panicln(err) - // } + if err != nil { + log.Panicln(err) + } var seed int64 = 1 p, err := rabinkarp64.RandomPolynomial(seed) if err != nil { @@ -244,18 +243,18 @@ func (r *Repo) StoreChunkContent(id *ChunkId, reader io.Reader) error { path := id.Path(r.path) file, err := os.Create(path) if err != nil { - return errors.New(fmt.Sprintf("Error creating chunk for '%s'; %s\n", path, err)) + return fmt.Errorf("Error creating chunk for '%s'; %s\n", path, err) } wrapper := r.chunkWriteWrapper(file) n, err := io.Copy(wrapper, reader) if err != nil { - return errors.New(fmt.Sprintf("Error writing chunk content for '%s', written %d bytes: %s\n", path, n, err)) + return fmt.Errorf("Error writing chunk content for '%s', written %d bytes: %s\n", path, n, err) } if err := wrapper.Close(); err != nil { - return errors.New(fmt.Sprintf("Error closing write wrapper for '%s': %s\n", path, err)) + return fmt.Errorf("Error closing write wrapper for '%s': %s\n", path, err) } if err := file.Close(); err != nil { - return errors.New(fmt.Sprintf("Error closing chunk for '%s': %s\n", path, err)) + return fmt.Errorf("Error closing chunk for '%s': %s\n", path, err) } return nil } diff --git a/repo_test.go b/repo_test.go index 93b1e75..1a19157 100644 --- a/repo_test.go +++ b/repo_test.go @@ -96,7 +96,8 @@ func storeChunks(dest string, chunks <-chan []byte) { } func TestReadFiles1(t *testing.T) { - repo := NewRepo("") + tmpDir := t.TempDir() + repo := NewRepo(tmpDir) chunkCount := 590/repo.chunkSize + 1 dataDir := path.Join("testdata", "logs", "1") files := []string{"logTest.log"} @@ -104,7 +105,8 @@ func TestReadFiles1(t *testing.T) { } func TestReadFiles2(t *testing.T) { - repo := NewRepo("") + tmpDir := t.TempDir() + repo := NewRepo(tmpDir) chunkCount := 22899/repo.chunkSize + 1 dataDir := path.Join("testdata", "logs", "2") files := []string{"csvParserTest.log", "slipdb.log"} @@ -112,7 +114,8 @@ func TestReadFiles2(t *testing.T) { } func TestReadFiles3(t *testing.T) { - repo := NewRepo("") + tmpDir := t.TempDir() + repo := NewRepo(tmpDir) chunkCount := 119398/repo.chunkSize + 1 dataDir := path.Join("testdata", "logs") files := []string{ |