Skip to content

Commit

Permalink
Add new line test
Browse files Browse the repository at this point in the history
  • Loading branch information
dadgar committed May 11, 2018
1 parent 8aaf074 commit 80ac8c2
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions client/driver/logging/rotator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,34 +183,27 @@ func TestFileRotator_RotateFiles_Boundary(t *testing.T) {
t.Fatalf("test setup err: %v", err)
}

// We will write two times:
// We will write three times:
// 1st: Write with new lines spanning two files
// 2nd: Write long string with no new lines
// 3rd: Write a single new line
expectations := [][]byte{
[]byte("ab\n"),
[]byte("cdef\n"),
[]byte("12345"),
[]byte("6789"),
[]byte("67890"),
[]byte("\n"),
}
str1 := "ab\ncdef\n"
str2 := "123456789"

nw, err := fr.Write([]byte(str1))
if err != nil {
t.Fatalf("got error while writing: %v", err)
}

if nw != len(str1) {
t.Fatalf("expected %v, got %v", len(str1), nw)
}

nw, err = fr.Write([]byte(str2))
if err != nil {
t.Fatalf("got error while writing: %v", err)
}
for _, str := range []string{"ab\ncdef\n", "1234567890", "\n"} {
nw, err := fr.Write([]byte(str))
if err != nil {
t.Fatalf("got error while writing: %v", err)
}

if nw != len(str2) {
t.Fatalf("expected %v, got %v", len(str2), nw)
if nw != len(str) {
t.Fatalf("expected %v, got %v", len(str), nw)
}
}

var lastErr error
Expand Down

0 comments on commit 80ac8c2

Please sign in to comment.