diff options
| author | Ben Navetta <[email protected]> | 2014-08-25 23:18:00 -0400 |
|---|---|---|
| committer | Ben Navetta <[email protected]> | 2014-08-25 23:18:00 -0400 |
| commit | 80997c6fa55da6a25c30dccab379e808d9f07b28 (patch) | |
| tree | edf2c583fd577e88ce77f5720bb523c666f3ba4b /status_test.go | |
| parent | 0059b26255190153337c3ce43c675606a044c1c1 (diff) | |
fix status list to handle null head_to_index in entries
Diffstat (limited to 'status_test.go')
| -rw-r--r-- | status_test.go | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/status_test.go b/status_test.go index 228ee0e..4be4824 100644 --- a/status_test.go +++ b/status_test.go @@ -23,22 +23,36 @@ func TestStatusFile(t *testing.T) { } } -func TestEntryCount(t *testing.T) { +func TestStatusList(t *testing.T) { repo := createTestRepo(t) + // This commits the test repo README, so it doesn't show up in the status list and there's a head to compare to + seedTestRepo(t, repo) defer repo.Free() defer os.RemoveAll(repo.Workdir()) err := ioutil.WriteFile(path.Join(path.Dir(repo.Workdir()), "hello.txt"), []byte("Hello, World"), 0644) checkFatal(t, err) - statusList, err := repo.StatusList(nil) + 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 != 1 { - // FIXME: this is 0 even though the same setup above returns the correct status, as does a call to StatusFile here - // t.Fatal("Incorrect number of status entries: ", entryCount) + t.Fatal("Incorrect number of status entries: ", entryCount) + } + + entry, err := statusList.ByIndex(0) + checkFatal(t, err) + if entry.Status != StatusWtNew { + t.Fatal("Incorrect status flags: ", entry.Status) + } + if entry.IndexToWorkdir.NewFile.Path != "hello.txt" { + t.Fatal("Incorrect entry path: ", entry.IndexToWorkdir.NewFile.Path) } } |
