Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ahrav committed Jan 30, 2024
1 parent d503a4e commit da07843
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/gitparse/gitparse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,7 @@ func TestMaxDiffSize(t *testing.T) {

select {
case commit := <-commitChan:
if commit.Diffs[0].Len() > parser.maxDiffSize+1024 {
if commit.Diffs[0].Len(ctx) > parser.maxDiffSize+1024 {
t.Errorf("diff did not match MaxDiffSize. Got: %d, expected (max): %d", commit.Diffs[0].Len(), parser.maxDiffSize+1024)

Check failure on line 1311 in pkg/gitparse/gitparse_test.go

View workflow job for this annotation

GitHub Actions / test

not enough arguments in call to commit.Diffs[0].Len

Check failure on line 1311 in pkg/gitparse/gitparse_test.go

View workflow job for this annotation

GitHub Actions / test

not enough arguments in call to commit.Diffs[0].Len
}
case <-ctx.Done():
Expand Down
7 changes: 6 additions & 1 deletion pkg/writers/buffered_file_writer/bufferedfilewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ func New(opts ...Option) *BufferedFileWriter {
}

// Len returns the number of bytes written to the buffer or file.
func (w *BufferedFileWriter) Len() int { return int(w.size) }
func (w *BufferedFileWriter) Len() (int, error) {
if w.state == writeOnly {
return 0, fmt.Errorf("BufferedFileWriter must be in read-only mode to get length")
}
return int(w.size), nil
}

// String returns all the data written to the buffer or file as a string or an empty string if there is an error.
func (w *BufferedFileWriter) String() (string, error) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/writers/buffered_file_writer/bufferedfilewriter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ func TestBufferedFileWriterLen(t *testing.T) {
_, err := writer.Write(context.Background(), tc.input)
assert.NoError(t, err)

length := writer.Len()
length, err := writer.Len()
assert.NoError(t, err)
assert.Equal(t, tc.expectedLen, length)
})
}
Expand Down

0 comments on commit da07843

Please sign in to comment.