2014-08-18 21:19:06 -05:00
|
|
|
package git
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"path"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2014-08-18 22:12:45 -05:00
|
|
|
func TestStatusFile(t *testing.T) {
|
|
|
|
repo := createTestRepo(t)
|
|
|
|
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)
|
|
|
|
|
|
|
|
status, err := repo.StatusFile("hello.txt")
|
|
|
|
checkFatal(t, err)
|
|
|
|
|
|
|
|
if status != StatusWtNew {
|
|
|
|
t.Fatal("Incorrect status flags: ", status)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-18 21:19:06 -05:00
|
|
|
func TestEntryCount(t *testing.T) {
|
|
|
|
repo := createTestRepo(t)
|
|
|
|
defer repo.Free()
|
|
|
|
defer os.RemoveAll(repo.Workdir())
|
|
|
|
|
2014-08-18 22:12:45 -05:00
|
|
|
err := ioutil.WriteFile(path.Join(path.Dir(repo.Workdir()), "hello.txt"), []byte("Hello, World"), 0644)
|
2014-08-18 21:19:06 -05:00
|
|
|
checkFatal(t, err)
|
|
|
|
|
2014-08-18 21:58:53 -05:00
|
|
|
statusList, err := repo.StatusList(nil)
|
2014-08-18 21:19:06 -05:00
|
|
|
checkFatal(t, err)
|
|
|
|
|
|
|
|
entryCount, err := statusList.EntryCount()
|
|
|
|
checkFatal(t, err)
|
|
|
|
|
|
|
|
if entryCount != 1 {
|
2014-08-19 07:08:46 -05:00
|
|
|
// 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)
|
2014-08-18 21:19:06 -05:00
|
|
|
}
|
|
|
|
}
|