start on status tests; fix bug in Repository.StatusList()
This commit is contained in:
parent
b831ae04aa
commit
f954871968
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue