-
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathstore_test.go
More file actions
87 lines (76 loc) · 2.59 KB
/
store_test.go
File metadata and controls
87 lines (76 loc) · 2.59 KB
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
package phpstore
import (
"path/filepath"
"sort"
"testing"
)
func TestBestVersion(t *testing.T) {
store := newEmpty("/dev/null", nil)
for _, v := range []string{"7.4.33", "8.0.27", "8.1.2", "8.1.14", "8.2.1"} {
ver := NewVersion(v)
ver.PHPPath = filepath.Join("/foo", v, "bin", "php")
store.addVersion(ver)
if !store.IsVersionAvailable(v) {
t.Errorf("Version %s should be shown as available", v)
}
}
{
v := "8.0.26"
ver := NewVersion(v)
ver.PHPPath = filepath.Join("/foo", v, "bin", "php")
ver.FPMPath = filepath.Join("/foo", v, "bin", "php-fpm")
store.addVersion(ver)
if !store.IsVersionAvailable(v) {
t.Errorf("Version %s should be shown as available", v)
}
}
sort.Sort(store.versions)
{
bestVersion, _, _, _ := store.bestVersion("8", "testing")
if bestVersion == nil {
t.Error("8 requirement should find a best version")
} else if bestVersion.Version != "8.2.1" {
t.Errorf("8 requirement should find 8.2.1 as best version, got %s", bestVersion.Version)
}
}
{
bestVersion, _, _, _ := store.bestVersion("8.1", "testing")
if bestVersion == nil {
t.Error("8.1 requirement should find a best version")
} else if bestVersion.Version != "8.1.14" {
t.Errorf("8.1 requirement should find 8.1.14 as best version, got %s", bestVersion.Version)
}
}
{
bestVersion, _, warning, _ := store.bestVersion("8.0.10", "testing")
if bestVersion == nil {
t.Error("8.0.10 requirement should find a best version")
} else if bestVersion.Version != "8.0.27" {
t.Errorf("8.0.10 requirement should find 8.0.27 as best version, got %s", bestVersion.Version)
} else if warning == "" {
t.Error("8.0.10 requirement should trigger a warning")
}
}
{
bestVersion, _, warning, _ := store.bestVersion("8.0.99", "testing")
if bestVersion == nil {
t.Error("8.0.99 requirement should find a best version")
} else if bestVersion.Version != "8.0.27" {
t.Errorf("8.0.99 requirement should find 8.0.27 as best version, got %s", bestVersion.Version)
} else if warning != "" {
t.Error("8.0.99 requirement should not trigger a warning")
}
}
{
bestVersion, _, warning, _ := store.bestVersion("8.0-fpm", "testing")
if bestVersion == nil {
t.Error("8.0-fpm requirement should find a best version")
} else if bestVersion.Version != "8.0.26" {
t.Errorf("8.0-fpm requirement should find 8.0.26 as best version, got %s", bestVersion.Version)
} else if bestVersion.serverType() != fpmServer {
t.Error("8.0-fpm requirement should find an FPM expectedFlavors")
} else if warning != "" {
t.Error("8.0-fpm requirement should not trigger a warning")
}
}
}