MCPcopy
hub / github.com/sourcegraph/checkup / TestGitHubWithoutSubdir

Function TestGitHubWithoutSubdir

storage/github/github_test.go:294–365  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

292}
293
294func TestGitHubWithoutSubdir(t *testing.T) {
295 // Our subject, our specimen.
296 specimen := &Storage{
297 RepositoryOwner: "o",
298 RepositoryName: "r",
299 CommitterName: "John Appleseed",
300 CommitterEmail: "appleseed@example.org",
301 Branch: "b",
302 Dir: "",
303 }
304
305 withGitHubServer(t, *specimen, func(client *github.Client) {
306 specimen.client = client
307
308 if err := specimen.Store(results); err != nil {
309 t.Fatalf("Expected no error from Store(), got: %v", err)
310 }
311
312 fmt.Println("Done with Store()")
313
314 // Make sure index has been created
315 index, _, err := specimen.readIndex()
316 if err != nil {
317 t.Fatalf("Cannot read index: %v", err)
318 }
319
320 if len(index) != 3 {
321 t.Fatalf("Expected length of index to be 3, but got %v", len(index))
322 }
323
324 var (
325 name string
326 nsec int64
327 )
328 for name, nsec = range index {
329 break
330 }
331
332 // Make sure index has timestamp of check
333 ts := time.Unix(0, nsec)
334 if time.Since(ts) > 1*time.Second {
335 t.Errorf("Timestamp of check is %s but expected something very recent", ts)
336 }
337
338 // Make sure check file bytes are correct
339 fmt.Printf("checking %s\n", name)
340 b, _, err := specimen.readFile(name)
341 if err != nil {
342 t.Fatalf("Expected no error reading body, got: %v", err)
343 }
344 if bytes.Compare(b, resultsBytes) != 0 {
345 t.Errorf("Contents of file are wrong\nExpected %s\nGot %s", resultsBytes, b)
346 }
347
348 // Make sure check file is not deleted after maintain with CheckExpiry == 0
349 if err := specimen.Maintain(); err != nil {
350 t.Fatalf("Expected no error, got %v", err)
351 }

Callers

nothing calls this directly

Calls 5

StoreMethod · 0.95
readIndexMethod · 0.95
readFileMethod · 0.95
MaintainMethod · 0.95
withGitHubServerFunction · 0.85

Tested by

no test coverage detected