You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Update Version regex to support ranges
Fixes#345
Add positive and negative test cases.
Signed-off-by: Todd Short <[email protected]>
* Introduce Masterminds/semver
Fixes#346
Add support for Masterminds/semver for .spec.Version
This is a bit more entangled into the code than I expected,
most instances of bsemver were replaced.
Signed-off-by: Todd Short <[email protected]>
* fixup! Introduce Masterminds/semver
Signed-off-by: Todd Short <[email protected]>
---------
Signed-off-by: Todd Short <[email protected]>
Expect(err).To(HaveOccurred(), "expected error for invalid semver %q", invalidSemver)
72
-
Expect(err.Error()).To(ContainSubstring("spec.version in body should match '^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(-(0|[1-9]\\d*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\\.(0|[1-9]\\d*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\\+([0-9a-zA-Z-]+(\\.[0-9a-zA-Z-]+)*))?$'"))
82
+
// Don't need to include the whole regex, this should be enough to match the MasterMinds regex
83
+
Expect(err.Error()).To(ContainSubstring("spec.version in body should match '^(\\s*(=||!=|>|<|>=|=>|<=|=<|~|~>|\\^)"))
84
+
}
85
+
})
86
+
It("should pass if a valid semver range given", func() {
87
+
validSemvers:= []string{
88
+
">=1.2.3",
89
+
"=>1.2.3",
90
+
">= 1.2.3",
91
+
">=v1.2.3",
92
+
">= v1.2.3",
93
+
"<=1.2.3",
94
+
"=<1.2.3",
95
+
"=1.2.3",
96
+
"!=1.2.3",
97
+
"<1.2.3",
98
+
">1.2.3",
99
+
"~1.2.2",
100
+
"~>1.2.3",
101
+
"^1.2.3",
102
+
"1.2.3",
103
+
"v1.2.3",
104
+
"1.x",
105
+
"1.X",
106
+
"1.*",
107
+
"1.2.x",
108
+
"1.2.X",
109
+
"1.2.*",
110
+
">=1.2.3 <2.3.4",
111
+
">=1.2.3,<2.3.4",
112
+
">=1.2.3, <2.3.4",
113
+
"<1.2.3||>2.3.4",
114
+
"<1.2.3|| >2.3.4",
115
+
"<1.2.3 ||>2.3.4",
116
+
"<1.2.3 || >2.3.4",
117
+
">1.0.0,<1.2.3 || >2.1.0",
118
+
"<1.2.3-abc >2.3.4-def",
119
+
"<1.2.3-abc+def >2.3.4-ghi+jkl",
120
+
}
121
+
for_, validSemver:=rangevalidSemvers {
122
+
op:=operator(operatorsv1alpha1.OperatorSpec{
123
+
PackageName: "package",
124
+
Version: validSemver,
125
+
})
126
+
err:=cl.Create(ctx, op)
127
+
Expect(err).NotTo(HaveOccurred(), "expected success for semver range '%q': %w", validSemver, err)
0 commit comments