From fe151849bb1990d48a407cef8bbd1b1a18a511a4 Mon Sep 17 00:00:00 2001 From: Yury Yantsevich Date: Wed, 17 Jun 2015 16:59:08 +0200 Subject: [PATCH] split max line size test to follow and nofollow version --- tail_test.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tail_test.go b/tail_test.go index 0b9c5f9..c20e2b6 100644 --- a/tail_test.go +++ b/tail_test.go @@ -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)