This repository has been archived by the owner on Feb 3, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
version_unifier_test.go
138 lines (109 loc) · 3.27 KB
/
version_unifier_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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package gps
import (
"testing"
"github.com/sdboyer/gps/pkgtree"
)
type lvFixBridge []Version
var lvfb1 lvFixBridge
func init() {
rev1 := Revision("revision-one")
rev2 := Revision("revision-two")
rev3 := Revision("revision-three")
lvfb1 = lvFixBridge{
NewBranch("master").Is(rev1),
NewBranch("test").Is(rev2),
NewVersion("1.0.0").Is(rev1),
NewVersion("1.0.1").Is("other1"),
NewVersion("v2.0.5").Is(rev3),
NewVersion("2.0.5.2").Is(rev3),
newDefaultBranch("unwrapped").Is(rev3),
NewVersion("20.0.5.2").Is(rev1),
NewVersion("v1.5.5-beta.4").Is("other2"),
NewVersion("v3.0.1-alpha.1").Is(rev2),
}
}
func (lb lvFixBridge) listVersions(ProjectIdentifier) ([]Version, error) {
return lb, nil
}
func TestCreateTyepUnion(t *testing.T) {
vu := versionUnifier{
b: lvfb1,
mtr: newMetrics(),
}
rev1 := Revision("revision-one")
rev2 := Revision("revision-two")
id := mkPI("irrelevant")
vtu := vu.createTypeUnion(id, rev1)
if len(vtu) != 4 {
t.Fatalf("wanted a type union with four elements, got %v: \n%#v", len(vtu), vtu)
}
vtu = vu.createTypeUnion(id, NewBranch("master"))
if len(vtu) != 4 {
t.Fatalf("wanted a type union with four elements, got %v: \n%#v", len(vtu), vtu)
}
vtu = vu.createTypeUnion(id, Revision("notexist"))
if len(vtu) != 1 {
t.Fatalf("wanted a type union with one elements, got %v: \n%#v", len(vtu), vtu)
}
vtu = vu.createTypeUnion(id, rev2)
if len(vtu) != 3 {
t.Fatalf("wanted a type union with three elements, got %v: \n%#v", len(vtu), vtu)
}
vtu = vu.createTypeUnion(id, nil)
if vtu != nil {
t.Fatalf("wanted a nil return on nil input, got %#v", vtu)
}
}
func TestTypeUnionIntersect(t *testing.T) {
vu := versionUnifier{
b: lvfb1,
mtr: newMetrics(),
}
rev1 := Revision("revision-one")
rev2 := Revision("revision-two")
rev3 := Revision("revision-three")
id := mkPI("irrelevant")
c, _ := NewSemverConstraint("^2.0.0")
gotc := vu.intersect(id, rev2, c)
if gotc != none {
t.Fatalf("wanted empty set from intersect, got %#v", gotc)
}
gotc = vu.intersect(id, c, rev1)
if gotc != none {
t.Fatalf("wanted empty set from intersect, got %#v", gotc)
}
gotc = vu.intersect(id, c, rev3)
if gotc != NewVersion("v2.0.5").Is(rev3) {
t.Fatalf("wanted v2.0.5, got %s from intersect", gotc.typedString())
}
}
func (lb lvFixBridge) SourceExists(ProjectIdentifier) (bool, error) {
panic("not implemented")
}
func (lb lvFixBridge) SyncSourceFor(ProjectIdentifier) error {
panic("not implemented")
}
func (lb lvFixBridge) RevisionPresentIn(ProjectIdentifier, Revision) (bool, error) {
panic("not implemented")
}
func (lb lvFixBridge) ListPackages(ProjectIdentifier, Version) (pkgtree.PackageTree, error) {
panic("not implemented")
}
func (lb lvFixBridge) GetManifestAndLock(ProjectIdentifier, Version, ProjectAnalyzer) (Manifest, Lock, error) {
panic("not implemented")
}
func (lb lvFixBridge) ExportProject(ProjectIdentifier, Version, string) error {
panic("not implemented")
}
func (lb lvFixBridge) DeduceProjectRoot(ip string) (ProjectRoot, error) {
panic("not implemented")
}
func (lb lvFixBridge) verifyRootDir(path string) error {
panic("not implemented")
}
func (lb lvFixBridge) vendorCodeExists(ProjectIdentifier) (bool, error) {
panic("not implemented")
}
func (lb lvFixBridge) breakLock() {
panic("not implemented")
}