split max line size test to follow and nofollow version

This commit is contained in:
Yury Yantsevich 2015-06-17 16:59:08 +02:00
parent 50aa2240d2
commit fe151849bb
1 changed files with 13 additions and 4 deletions

View File

@ -54,11 +54,11 @@ func TestStop(t *testing.T) {
Cleanup()
}
func TestMaxLineSize(_t *testing.T) {
func MaxLineSizeT(_t *testing.T, follow bool, fileContent string, expected []string) {
t := NewTailTest("maxlinesize", _t)
t.CreateFile("test.txt", "hello\nworld\nfin\nhe")
tail := t.StartTail("test.txt", Config{Follow: true, Location: nil, MaxLineSize: 3})
go t.VerifyTailOutput(tail, []string{"hel", "lo", "wor", "ld", "fin", "he"})
t.CreateFile("test.txt", fileContent)
tail := t.StartTail("test.txt", Config{Follow: follow, Location: nil, MaxLineSize: 3})
go t.VerifyTailOutput(tail, expected)
// Delete after a reasonable delay, to give tail sufficient time
// to read all lines.
@ -68,6 +68,15 @@ func TestMaxLineSize(_t *testing.T) {
Cleanup()
}
func TestMaxLineSizeFollow(_t *testing.T) {
// As last file line does not end with newline, it will not be present in tail's output
MaxLineSizeT(_t, true, "hello\nworld\nfin\nhe", []string{"hel", "lo", "wor", "ld", "fin"})
}
func TestMaxLineSizeNoFollow(_t *testing.T) {
MaxLineSizeT(_t, false, "hello\nworld\nfin\nhe", []string{"hel", "lo", "wor", "ld", "fin", "he"})
}
func TestOver4096ByteLine(_t *testing.T) {
t := NewTailTest("Over4096ByteLine", _t)
testString := strings.Repeat("a", 4097)