MCPcopy Create free account
hub / github.com/hpcloud/tail / ReadLines

Method ReadLines

tail_test.go:490–513  ·  view source on GitHub ↗
(tail *Tail, lines []string)

Source from the content-addressed store, hash-verified

488}
489
490func (t TailTest) ReadLines(tail *Tail, lines []string) {
491 for idx, line := range lines {
492 tailedLine, ok := <-tail.Lines
493 if !ok {
494 // tail.Lines is closed and empty.
495 err := tail.Err()
496 if err != nil {
497 t.Fatalf("tail ended with error: %v", err)
498 }
499 t.Fatalf("tail ended early; expecting more: %v", lines[idx:])
500 }
501 if tailedLine == nil {
502 t.Fatalf("tail.Lines returned nil; not possible")
503 }
504 // Note: not checking .Err as the `lines` argument is designed
505 // to match error strings as well.
506 if tailedLine.Text != line {
507 t.Fatalf(
508 "unexpected line/err from tail: "+
509 "expecting <<%s>>>, but got <<<%s>>>",
510 line, tailedLine.Text)
511 }
512 }
513}
514
515func (t TailTest) Cleanup(tail *Tail, stop bool) {
516 <-t.done

Callers 2

reOpenFunction · 0.95
VerifyTailOutputMethod · 0.95

Calls 1

FatalfMethod · 0.80

Tested by

no test coverage detected