(t *testing.T)
| 408 | } |
| 409 | |
| 410 | func TestListHttpFile(t *testing.T) { |
| 411 | files := map[string]struct { |
| 412 | // alternative fields |
| 413 | lines int64 // number of random lines |
| 414 | files []string // file names to include |
| 415 | }{ |
| 416 | "/test7.log.gz": {lines: 7}, |
| 417 | "/test100.log.gz": {lines: 100}, |
| 418 | "/test500.log.gz": {lines: 500}, |
| 419 | "/test1233.log.gz": {lines: 1233}, |
| 420 | "/testlist600": {files: []string{"/test100.log.gz", "/test500.log.gz"}}, |
| 421 | "/buglist": {files: []string{"/test100.log.gz", "/nonesisting.log.gz"}}, |
| 422 | } |
| 423 | ts := newHTTPFileServer(t, files) |
| 424 | defer ts.Close() |
| 425 | |
| 426 | var tests = []struct { |
| 427 | files []string |
| 428 | lines int64 // -1 for error |
| 429 | }{ |
| 430 | {[]string{ts.URL + "/test7.log.gz"}, 7}, |
| 431 | {[]string{ts.URL + "/test1233.log.gz"}, 1233}, |
| 432 | {[]string{ |
| 433 | ts.URL + "/test100.log.gz", |
| 434 | ts.URL + "/test500.log.gz", |
| 435 | }, 600}, |
| 436 | {[]string{"@" + ts.URL + "/testlist600"}, 600}, |
| 437 | {[]string{ |
| 438 | ts.URL + "/test100.log.gz", |
| 439 | "@" + ts.URL + "/testlist600", |
| 440 | ts.URL + "/test7.log.gz", |
| 441 | }, 707}, |
| 442 | // errors |
| 443 | {[]string{ |
| 444 | ts.URL + "/test100.log.gz", |
| 445 | ts.URL + "/nonexisting2.log.gz", |
| 446 | }, -1}, |
| 447 | {[]string{"@" + ts.URL + "/notexistinglist"}, -1}, |
| 448 | {[]string{ |
| 449 | "@" + ts.URL + "/buglist", |
| 450 | ts.URL + "/test100.log.gz", |
| 451 | }, -1}, |
| 452 | } |
| 453 | |
| 454 | ch := make(chan *baker.Data) |
| 455 | defer close(ch) |
| 456 | var counter int64 |
| 457 | go func() { |
| 458 | for data := range ch { |
| 459 | atomic.AddInt64(&counter, int64(bytes.Count(data.Bytes, []byte{'\n'}))) |
| 460 | // Check the metadata contains a valid last modified date |
| 461 | if v := data.Meta["last_modified"]; v.(time.Time).IsZero() { |
| 462 | t.Errorf("Invalid last modified time in file, it should not be zero") |
| 463 | } |
| 464 | } |
| 465 | }() |
| 466 | |
| 467 | for _, tt := range tests { |
nothing calls this directly
no test coverage detected