From a2b8cf952a58cfad876ea14795994a7fb805ce98 Mon Sep 17 00:00:00 2001 From: Michael Boulton Date: Fri, 14 Aug 2020 11:05:58 +0100 Subject: [PATCH] Add test for no statuses --- status_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/status_test.go b/status_test.go index 17ed94f..9b82907 100644 --- a/status_test.go +++ b/status_test.go @@ -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") + } +}