MCPcopy Create free account
hub / github.com/libgit2/git2go / checkSecondFileStaged

Function checkSecondFileStaged

diff_test.go:598–628  ·  view source on GitHub ↗

checkSecondFileStaged checks that there is a single file called "file2" uncommitted in the repo

(t *testing.T, repo *Repository)

Source from the content-addressed store, hash-verified

596
597// checkSecondFileStaged checks that there is a single file called "file2" uncommitted in the repo
598func checkSecondFileStaged(t *testing.T, repo *Repository) {
599 opts := StatusOptions{
600 Show: StatusShowIndexAndWorkdir,
601 Flags: StatusOptIncludeUntracked,
602 }
603
604 statuses, err := repo.StatusList(&opts)
605 checkFatal(t, err)
606
607 count, err := statuses.EntryCount()
608 checkFatal(t, err)
609
610 if count != 1 {
611 t.Error("diff should affect exactly one file")
612 }
613 if count == 0 {
614 t.Fatal("no statuses, cannot continue test")
615 }
616
617 entry, err := statuses.ByIndex(0)
618 checkFatal(t, err)
619
620 if entry.Status != StatusIndexNew {
621 t.Error("status should be 'new' as file has been added between commits")
622 }
623
624 if entry.HeadToIndex.NewFile.Path != "file2" {
625 t.Error("new file should be 'file2")
626 }
627 return
628}
629
630// checkNoFilesStaged checks that there is a single file called "file2" uncommitted in the repo
631func checkNoFilesStaged(t *testing.T, repo *Repository) {

Callers 1

TestApplyDiffAddfileFunction · 0.85

Calls 5

checkFatalFunction · 0.85
StatusListMethod · 0.80
ErrorMethod · 0.80
ByIndexMethod · 0.80
EntryCountMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…