start on status tests; fix bug in Repository.StatusList()

This commit is contained in:
Ben Navetta 2014-08-18 22:19:06 -04:00
parent b831ae04aa
commit f954871968
2 changed files with 30 additions and 3 deletions

View File

@ -121,17 +121,17 @@ func (v *Repository) Index() (*Index, error) {
func (v *Repository) StatusList() (*StatusList, error) {
var ptr *C.git_status_list
var options *C.git_status_options
options := C.git_status_options{}
runtime.LockOSThread()
defer runtime.UnlockOSThread()
ret := C.git_status_init_options(options, C.GIT_STATUS_OPTIONS_VERSION)
ret := C.git_status_init_options(&options, C.GIT_STATUS_OPTIONS_VERSION)
if ret < 0 {
return nil, MakeGitError(ret)
}
ret = C.git_status_list_new(&ptr, v.ptr, options)
ret = C.git_status_list_new(&ptr, v.ptr, &options)
if ret < 0 {
return nil, MakeGitError(ret)
}

27
status_test.go Normal file
View File

@ -0,0 +1,27 @@
package git
import (
"io/ioutil"
"os"
"path"
"testing"
)
func TestEntryCount(t *testing.T) {
repo := createTestRepo(t)
defer repo.Free()
defer os.RemoveAll(repo.Workdir())
err := ioutil.WriteFile(path.Join(path.Dir(repo.Path()), "hello.txt"), []byte("Hello, World"), 0644)
checkFatal(t, err)
statusList, err := repo.StatusList()
checkFatal(t, err)
entryCount, err := statusList.EntryCount()
checkFatal(t, err)
if entryCount != 1 {
t.Fatal("Incorrect number of status entries: ", entryCount)
}
}