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
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-]+)*))?$'"))
81
+
// Don't need to include the whole regex, this should be enough to match the MasterMinds regex
82
+
Expect(err.Error()).To(ContainSubstring("spec.version in body should match '^(\\s*(=||!=|>|<|>=|=>|<=|=<|~|~>|\\^)"))
83
+
}
84
+
})
85
+
It("should pass if a valid semver range given", func() {
86
+
validSemvers:= []string{
87
+
">=1.2.3",
88
+
"=>1.2.3",
89
+
">= 1.2.3",
90
+
">=v1.2.3",
91
+
">= v1.2.3",
92
+
"<=1.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.2",
99
+
"~>1.2.3",
100
+
"^1.2.3",
101
+
"1.2.3",
102
+
"v1.2.3",
103
+
"1.x",
104
+
"1.X",
105
+
"1.*",
106
+
"1.2.x",
107
+
"1.2.X",
108
+
"1.2.*",
109
+
">=1.2.3 <2.3.4",
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.0.0,<1.2.3 || >2.1.0",
117
+
"<1.2.3-abc >2.3.4-def",
118
+
"<1.2.3-abc+def >2.3.4-ghi+jkl",
119
+
}
120
+
for_, validSemver:=rangevalidSemvers {
121
+
op:=operator(operatorsv1alpha1.OperatorSpec{
122
+
PackageName: "package",
123
+
Version: validSemver,
124
+
})
125
+
err:=cl.Create(ctx, op)
126
+
Expect(err).NotTo(HaveOccurred(), "expected success for semver range '%q': %w", validSemver, err)
0 commit comments