From 1cb654e4f2ae536f71773dbe0bd808874b832d9c Mon Sep 17 00:00:00 2001 From: Ben Navetta Date: Tue, 19 Aug 2014 08:51:18 -0400 Subject: add git_status_foreach binding --- status_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'status_test.go') diff --git a/status_test.go b/status_test.go index 228ee0e..a0ff1d3 100644 --- a/status_test.go +++ b/status_test.go @@ -23,6 +23,29 @@ func TestStatusFile(t *testing.T) { } } +func TestStatusForeach(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) + + statusFound := false + err = repo.StatusForeach(func (path string, statusFlags Status) int { + if path == "hello.txt" && statusFlags & StatusWtNew != 0 { + statusFound = true + } + + return 0 + }); + checkFatal(t, err) + + if !statusFound { + t.Fatal("Status callback not called with the new file") + } +} + func TestEntryCount(t *testing.T) { repo := createTestRepo(t) defer repo.Free() -- cgit v1.2.3