(t *testing.T)
| 365 | } |
| 366 | |
| 367 | func TestGitHubWithSubdir(t *testing.T) { |
| 368 | // Our subject, our specimen. |
| 369 | specimen := &Storage{ |
| 370 | RepositoryOwner: "o", |
| 371 | RepositoryName: "r", |
| 372 | CommitterName: "John Appleseed", |
| 373 | CommitterEmail: "appleseed@example.org", |
| 374 | Branch: "b", |
| 375 | Dir: "subdir/", |
| 376 | } |
| 377 | |
| 378 | withGitHubServer(t, *specimen, func(client *github.Client) { |
| 379 | specimen.client = client |
| 380 | |
| 381 | if err := specimen.Store(results); err != nil { |
| 382 | t.Fatalf("Expected no error from Store(), got: %v", err) |
| 383 | } |
| 384 | |
| 385 | fmt.Println("Done with Store()") |
| 386 | |
| 387 | // Make sure index has been created |
| 388 | index, _, err := specimen.readIndex() |
| 389 | if err != nil { |
| 390 | t.Fatalf("Cannot read index: %v", err) |
| 391 | } |
| 392 | |
| 393 | if len(index) != 3 { |
| 394 | t.Fatalf("Expected length of index to be 3, but got %v", len(index)) |
| 395 | } |
| 396 | |
| 397 | var ( |
| 398 | name string |
| 399 | nsec int64 |
| 400 | ) |
| 401 | for name, nsec = range index { |
| 402 | break |
| 403 | } |
| 404 | |
| 405 | // Make sure index has timestamp of check |
| 406 | ts := time.Unix(0, nsec) |
| 407 | if time.Since(ts) > 1*time.Second { |
| 408 | t.Errorf("Timestamp of check is %s but expected something very recent", ts) |
| 409 | } |
| 410 | |
| 411 | // Make sure check file bytes are correct |
| 412 | checkfile := filepath.Join(specimen.Dir, name) |
| 413 | fmt.Printf("checking %s\n", checkfile) |
| 414 | b, _, err := specimen.readFile(checkfile) |
| 415 | if err != nil { |
| 416 | t.Fatalf("Expected no error reading body, got: %v", err) |
| 417 | } |
| 418 | if bytes.Compare(b, resultsBytes) != 0 { |
| 419 | t.Errorf("Contents of file are wrong\nExpected %s\nGot %s", resultsBytes, b) |
| 420 | } |
| 421 | |
| 422 | // Make sure check file is not deleted after maintain with CheckExpiry == 0 |
| 423 | if err := specimen.Maintain(); err != nil { |
| 424 | t.Fatalf("Expected no error, got %v", err) |
nothing calls this directly
no test coverage detected