2015-01-28 08:03:58 -06:00
|
|
|
package git
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestSubmoduleForeach(t *testing.T) {
|
|
|
|
repo := createTestRepo(t)
|
2015-04-24 05:59:29 -05:00
|
|
|
defer cleanupTestRepo(t, repo)
|
|
|
|
|
2015-01-28 08:03:58 -06:00
|
|
|
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 {
|
2015-05-30 15:27:08 -05:00
|
|
|
t.Fatalf("expected one submodule found but got %d", i)
|
2015-01-28 08:03:58 -06:00
|
|
|
}
|
|
|
|
}
|