Skip to content

Commit

Permalink
Additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
banjoh committed Sep 15, 2023
1 parent 61efb30 commit 3587249
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/redact/multi_line.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (r *MultiLineRedactor) Redact(input io.Reader, path string) io.Reader {
line1, line2, err := getNextTwoLines(reader, nil)
if err != nil {
// this will print 2 blank lines for empty input...
// Append newlines since scanner strip them
// Append newlines since scanner strips them
err = writeBytes(writer, line1, NEW_LINE, line2, NEW_LINE)
if err != nil {
return
Expand Down Expand Up @@ -96,7 +96,7 @@ func (r *MultiLineRedactor) Redact(input io.Reader, path string) io.Reader {
flushLastLine = false
clean := r.re2.ReplaceAll(line2, substStr)

// Append newlines since scanner strip them
// Append newlines since scanner strips them
err = writeBytes(writer, line1, NEW_LINE, clean, NEW_LINE)
if err != nil {
return
Expand Down
8 changes: 8 additions & 0 deletions pkg/redact/multi_line_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ func Test_writeBytes(t *testing.T) {
inputBytes: [][]byte{[]byte("hello"), NEW_LINE, []byte("world"), NEW_LINE},
want: "hello\nworld\n",
},
{
name: "Empty line",
inputBytes: [][]byte{NEW_LINE},
want: "\n",
},
{
name: "Nothing",
},
}

for _, tt := range tests {
Expand Down

0 comments on commit 3587249

Please sign in to comment.