Add test for no statuses

This commit is contained in:
Michael Boulton 2020-08-14 11:05:58 +01:00
parent 5b2c47f6b7
commit a2b8cf952a
No known key found for this signature in database
GPG Key ID: 8A62CA0BE2E0197E
1 changed files with 27 additions and 0 deletions

View File

@ -61,3 +61,30 @@ func TestStatusList(t *testing.T) {
t.Fatal("Incorrect entry path: ", entry.IndexToWorkdir.NewFile.Path)
}
}
func TestStatusNothing(t *testing.T) {
t.Parallel()
repo := createTestRepo(t)
defer cleanupTestRepo(t, repo)
seedTestRepo(t, repo)
opts := &StatusOptions{}
opts.Show = StatusShowIndexAndWorkdir
opts.Flags = StatusOptIncludeUntracked | StatusOptRenamesHeadToIndex | StatusOptSortCaseSensitively
statusList, err := repo.StatusList(opts)
checkFatal(t, err)
entryCount, err := statusList.EntryCount()
checkFatal(t, err)
if entryCount != 0 {
t.Error("expected no statuses in empty repo")
}
_, err = statusList.ByIndex(0)
if err == nil {
t.Error("expected error getting status by index")
}
}