(t *testing.T)
| 259 | } |
| 260 | |
| 261 | func 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 | |
| 295 | func TestBlockUntilExists(t *testing.T) { |
| 296 | tailTest := NewTailTest("block-until-file-exists", t) |
nothing calls this directly
no test coverage detected
searching dependent graphs…