toyohime/main_test.go
kare.nuorteva 550d9d29f2 Rename public to private
git-svn-id: file:///srv/svn/repo/toyohime/trunk@49 922d331f-388e-da47-97a9-ad700dc0b8b9
2017-05-07 16:16:43 +00:00

39 lines
964 B
Go

package main
import (
"reflect"
"strings"
"testing"
)
func TestParseConfig(t *testing.T) {
config := `/gist git https://github.com/kare/gist
/vanity git https://github.com/kare/vanity
`
expected := map[string]*packageConfig{
"/gist": newPackage("/gist", "git", "https://github.com/kare/gist"),
"/vanity": newPackage("/vanity", "git", "https://github.com/kare/vanity"),
}
packages, err := readConfig(strings.NewReader(config))
if err != nil {
t.Fatalf("unexcepted configuration error: %v", err)
}
if len(packages) != 2 {
t.Fatalf("expecting config for %v packages, but got %v", 4, len(packages))
}
for key, pack := range expected {
if !reflect.DeepEqual(pack, packages[key]) {
t.Fatalf("expected %v but got %v", pack, packages[key])
}
}
}
func TestParseBrokenConfig(t *testing.T) {
config := "/gist git"
_, err := readConfig(strings.NewReader(config))
if err == nil {
t.Fatal("broken configuration did not return error")
}
}