forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminimum_version_check_test.go
106 lines (94 loc) · 3.29 KB
/
minimum_version_check_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
package command_test
import (
. "code.cloudfoundry.org/cli/command"
"code.cloudfoundry.org/cli/command/translatableerror"
"code.cloudfoundry.org/cli/version"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Minimum Version Check", func() {
Describe("MinimumCFAPIVersionCheck", func() {
minimumVersion := "1.0.0"
Context("current version is greater than min", func() {
It("does not return an error", func() {
currentVersion := "1.0.1"
err := MinimumCCAPIVersionCheck(currentVersion, minimumVersion)
Expect(err).ToNot(HaveOccurred())
})
})
Context("current version is less than min", func() {
It("does return an error", func() {
currentVersion := "1.0.0-alpha.5"
err := MinimumCCAPIVersionCheck(currentVersion, minimumVersion)
Expect(err).To(MatchError(translatableerror.MinimumCFAPIVersionNotMetError{
CurrentVersion: currentVersion,
MinimumVersion: minimumVersion,
}))
})
When("a custom command is provided", func() {
currentVersion := "1.0.0-alpha.5"
It("sets the command on the MinimumAPIVersionNotMetError", func() {
err := MinimumCCAPIVersionCheck(currentVersion, minimumVersion, "some-command")
Expect(err).To(MatchError(translatableerror.MinimumCFAPIVersionNotMetError{
Command: "some-command",
CurrentVersion: currentVersion,
MinimumVersion: minimumVersion,
}))
})
})
})
Context("current version is the default version", func() {
It("does not return an error", func() {
err := MinimumCCAPIVersionCheck(version.DefaultVersion, minimumVersion)
Expect(err).ToNot(HaveOccurred())
})
})
Context("minimum version is empty", func() {
It("does not return an error", func() {
err := MinimumCCAPIVersionCheck("2.0.0", "")
Expect(err).ToNot(HaveOccurred())
})
})
})
Describe("MinimumUAAAPIVersionCheck", func() {
minimumVersion := "1.0.0"
Context("current version is greater than min", func() {
It("does not return an error", func() {
currentVersion := "1.0.1"
err := MinimumUAAAPIVersionCheck(currentVersion, minimumVersion)
Expect(err).ToNot(HaveOccurred())
})
})
Context("current version is less than min", func() {
It("does return an error", func() {
currentVersion := "1.0.0-alpha.5"
err := MinimumUAAAPIVersionCheck(currentVersion, minimumVersion)
Expect(err).To(MatchError(translatableerror.MinimumUAAAPIVersionNotMetError{
MinimumVersion: minimumVersion,
}))
})
When("a custom command is provided", func() {
currentVersion := "1.0.0-alpha.5"
It("sets the command on the MinimumAPIVersionNotMetError", func() {
err := MinimumUAAAPIVersionCheck(currentVersion, minimumVersion, "some-command")
Expect(err).To(MatchError(translatableerror.MinimumUAAAPIVersionNotMetError{
Command: "some-command",
MinimumVersion: minimumVersion,
}))
})
})
})
Context("current version is the default version", func() {
It("does not return an error", func() {
err := MinimumUAAAPIVersionCheck(version.DefaultVersion, minimumVersion)
Expect(err).ToNot(HaveOccurred())
})
})
Context("minimum version is empty", func() {
It("does not return an error", func() {
err := MinimumUAAAPIVersionCheck("2.0.0", "")
Expect(err).ToNot(HaveOccurred())
})
})
})
})