-
Notifications
You must be signed in to change notification settings - Fork 1
/
requirements_test.go
94 lines (89 loc) · 1.4 KB
/
requirements_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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package cheerio
import (
"github.com/kr/pretty"
"reflect"
"testing"
)
func TestParseRequirements(t *testing.T) {
expReqs := []*Requirement{
{
Name: "dep1",
Constraint: "==",
Version: "2.3.2",
},
{
Name: "dep2",
Constraint: ">=",
Version: "1.0",
},
{
Name: "dep3",
Constraint: "",
Version: "",
},
{
Name: "dep4",
Constraint: "",
Version: "",
},
{
Name: "dep5",
Constraint: "==",
Version: "2.3.2",
},
{
Name: "dep6",
Constraint: ">=",
Version: "7",
},
{
Name: "dep7",
Constraint: "==",
Version: "10",
},
{
Name: "dep8.subdep",
Constraint: "==",
Version: "1.2.3",
},
{
Name: "dep9",
Constraint: ">",
Version: "1",
},
{
Name: "dep9",
Constraint: ">",
Version: "1",
},
{
Name: "dep10",
Constraint: "==",
Version: "1",
},
{
Name: "dep10",
Constraint: "",
Version: "",
},
}
reqs, err := ParseRequirements(`dep1==2.3.2
dep2>=1.0
dep3
dep4
dep5 == 2.3.2
dep6>= 7
[this-is-a-heading]
dep7 ==10
dep8.subdep==1.2.3
dep9>1
dep9 > 1
dep10[extradep]==1
dep10[extradep]
`)
if err != nil {
t.Errorf("Error parsing requirements: %s", err)
} else if !reflect.DeepEqual(reqs, expReqs) {
t.Errorf("Requirements do not match: %v", pretty.Diff(reqs, expReqs))
}
}