Add test triggering ForeachSubmodule panic.

This commit is contained in:
Patrick Steinhardt 2015-01-28 15:03:58 +01:00
parent 4a17f8038d
commit 1107c6824f
1 changed files with 24 additions and 0 deletions

24
submodule_test.go Normal file
View File

@ -0,0 +1,24 @@
package git
import (
"testing"
)
func TestSubmoduleForeach(t *testing.T) {
repo := createTestRepo(t)
seedTestRepo(t, repo)
_, err := repo.AddSubmodule("http://example.org/submodule", "submodule", true)
checkFatal(t, err)
i := 0
err = repo.ForeachSubmodule(func(sub *Submodule, name string) int {
i++
return 0
})
checkFatal(t, err)
if i != 1 {
t.Fatalf("expected one submodule found but got %i", i)
}
}