MCPcopy Create free account
hub / github.com/devspace-sh/devspace / TestConstraint_sort

Function TestConstraint_sort

pkg/util/constraint/constraint_test.go:161–201  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

159}
160
161func TestConstraint_sort(t *testing.T) {
162 cases := []struct {
163 constraint string
164 expectedConstraints string
165 }{
166 {
167 ">= 0.1.0,< 1.12",
168 "< 1.12,>= 0.1.0",
169 },
170 {
171 "< 1.12,>= 0.1.0",
172 "< 1.12,>= 0.1.0",
173 },
174 {
175 "< 1.12,>= 0.1.0,0.2.0",
176 "< 1.12,0.2.0,>= 0.1.0",
177 },
178 {
179 ">1.0,>0.1.0,>0.3.0,>0.2.0",
180 ">0.1.0,>0.2.0,>0.3.0,>1.0",
181 },
182 }
183
184 for i, tc := range cases {
185 t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
186 c, err := NewConstraint(tc.constraint)
187 if err != nil {
188 t.Fatalf("err: %s", err)
189 }
190
191 sort.Sort(c)
192
193 actual := c.String()
194
195 if !reflect.DeepEqual(actual, tc.expectedConstraints) {
196 t.Fatalf("unexpected order\nexpected: %#v\nactual: %#v",
197 tc.expectedConstraints, actual)
198 }
199 })
200 }
201}
202
203func TestConstraintsString(t *testing.T) {
204 cases := []struct {

Callers

nothing calls this directly

Calls 4

StringMethod · 0.95
NewConstraintFunction · 0.85
RunMethod · 0.65
FatalfMethod · 0.45

Tested by

no test coverage detected