-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathparse_test.go
44 lines (37 loc) · 907 Bytes
/
parse_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package vagrantutil
import "testing"
const version174 = `
1459267732,,version-installed,1.7.4
1459267732,,version-latest,1.8.1
`
const version181 = `
1459268273,,ui,output,Installed Version: 1.8.1
1459268273,,version-installed,1.8.1
1459268273,,ui,output,Latest Version: 1.8.1
1459268273,,version-latest,1.8.1
1459268273,,ui,success, \nYou're running an up-to-date version of Vagrant!
`
func TestParseRecordsAndData(t *testing.T) {
cases := []struct {
raw string
ver string
}{
{version174, "1.7.4"}, // i=0
{version181, "1.8.1"}, // i=1
}
for i, cas := range cases {
rec, err := parseRecords(cas.raw)
if err != nil {
t.Errorf("%d: parseRecords()=%s", i, err)
continue
}
ver, err := parseData(rec, "version-installed")
if err != nil {
t.Errorf("%d: parseData()=%d", i, err)
continue
}
if ver != cas.ver {
t.Errorf("%d: got %q, want %q", ver, cas.ver)
}
}
}