vcs as string, not int.

No longer do we keep track of const iota style. Just encode the behavior
in the server for defaults, add a validation function, call it a day.

Change-Id: I603e9dd287a57084c78c543f1ce83b0acf47a765
This commit is contained in:
sm
2016-03-01 23:49:24 -08:00
parent a1f6e15f28
commit ce00d933aa
7 changed files with 151 additions and 83 deletions
+13 -9
View File
@@ -7,6 +7,7 @@ import (
func TestString(t *testing.T) {
p := Package{
Vcs: "git",
path: "mcquay.me/bps",
Repo: "https://s.mcquay.me/sm/bps",
}
@@ -21,19 +22,22 @@ func TestString(t *testing.T) {
}
}
func TestVcsStrings(t *testing.T) {
func TestSupportedVcsStrings(t *testing.T) {
tests := []struct {
got string
want string
in string
want bool
}{
{fmt.Sprintf("%+v", Git), "git"},
{fmt.Sprintf("%+v", Hg), "mercurial"},
{fmt.Sprintf("%+v", Svn), "svn"},
{fmt.Sprintf("%+v", Bzr), "bazaar"},
{"hg", true},
{"git", true},
{"bzr", true},
{"", false},
{"bazar", false},
{"mercurial", false},
}
for _, test := range tests {
if test.got != test.want {
t.Errorf("incorrect conversion of vain.Vcs -> string; got %q, want %q", test.got, test.want)
if got, want := valid(test.in), test.want; got != want {
t.Errorf("%s: %t is incorrect validity", test.in, got)
}
}
}