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

Function TestTell

tail_test.go:261–293  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

259}
260
261func TestTell(t *testing.T) {
262 tailTest := NewTailTest("tell-position", t)
263 tailTest.CreateFile("test.txt", "hello\nworld\nagain\nmore\n")
264 config := Config{
265 Follow: false,
266 Location: &SeekInfo{0, os.SEEK_SET}}
267 tail := tailTest.StartTail("test.txt", config)
268 // read noe line
269 <-tail.Lines
270 offset, err := tail.Tell()
271 if err != nil {
272 tailTest.Errorf("Tell return error: %s", err.Error())
273 }
274 tail.Done()
275 // tail.close()
276
277 config = Config{
278 Follow: false,
279 Location: &SeekInfo{offset, os.SEEK_SET}}
280 tail = tailTest.StartTail("test.txt", config)
281 for l := range tail.Lines {
282 // it may readed one line in the chan(tail.Lines),
283 // so it may lost one line.
284 if l.Text != "world" && l.Text != "again" {
285 tailTest.Fatalf("mismatch; expected world or again, but got %s",
286 l.Text)
287 }
288 break
289 }
290 tailTest.RemoveFile("test.txt")
291 tail.Done()
292 tail.Cleanup()
293}
294
295func TestBlockUntilExists(t *testing.T) {
296 tailTest := NewTailTest("block-until-file-exists", t)

Callers

nothing calls this directly

Calls 7

CreateFileMethod · 0.95
StartTailMethod · 0.95
RemoveFileMethod · 0.95
NewTailTestFunction · 0.85
TellMethod · 0.80
FatalfMethod · 0.80
CleanupMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…