(t *testing.T)
| 231 | } |
| 232 | |
| 233 | func TestRateLimiting(t *testing.T) { |
| 234 | tailTest := NewTailTest("rate-limiting", t) |
| 235 | tailTest.CreateFile("test.txt", "hello\nworld\nagain\nextra\n") |
| 236 | config := Config{ |
| 237 | Follow: true, |
| 238 | RateLimiter: ratelimiter.NewLeakyBucket(2, time.Second)} |
| 239 | leakybucketFull := "Too much log activity; waiting a second before resuming tailing" |
| 240 | tail := tailTest.StartTail("test.txt", config) |
| 241 | |
| 242 | // TODO: also verify that tail resumes after the cooloff period. |
| 243 | go tailTest.VerifyTailOutput(tail, []string{ |
| 244 | "hello", "world", "again", |
| 245 | leakybucketFull, |
| 246 | "more", "data", |
| 247 | leakybucketFull}, false) |
| 248 | |
| 249 | // Add more data only after reasonable delay. |
| 250 | <-time.After(1200 * time.Millisecond) |
| 251 | tailTest.AppendFile("test.txt", "more\ndata\n") |
| 252 | |
| 253 | // Delete after a reasonable delay, to give tail sufficient time |
| 254 | // to read all lines. |
| 255 | <-time.After(100 * time.Millisecond) |
| 256 | tailTest.RemoveFile("test.txt") |
| 257 | |
| 258 | tailTest.Cleanup(tail, true) |
| 259 | } |
| 260 | |
| 261 | func TestTell(t *testing.T) { |
| 262 | tailTest := NewTailTest("tell-position", t) |
nothing calls this directly
no test coverage detected
searching dependent graphs…