@@ -243,6 +243,8 @@ func TestNewConstraint(t *testing.T) {
243
243
{"12.3.34.1234" , 0 , 0 , true },
244
244
{"12.3.34 ~1.2.3" , 1 , 2 , false },
245
245
{"12.3.34~ 1.2.3" , 0 , 0 , true },
246
+
247
+ {"1.0.0 - 2.0.0, <=2.0.0" , 1 , 3 , false },
246
248
}
247
249
248
250
for _ , tc := range tests {
@@ -394,6 +396,10 @@ func TestConstraintsCheck(t *testing.T) {
394
396
{"~1.2.3" , "1.3.2" , false },
395
397
{"~1.1" , "1.2.3" , false },
396
398
{"~1.3" , "2.4.5" , false },
399
+
400
+ // Ranges should work in conjunction with other constraints anded together.
401
+ {"1.0.0 - 2.0.0 <=2.0.0" , "1.5.0" , true },
402
+ {"1.0.0 - 2.0.0, <=2.0.0" , "1.5.0" , true },
397
403
}
398
404
399
405
for _ , tc := range tests {
@@ -421,16 +427,18 @@ func TestRewriteRange(t *testing.T) {
421
427
c string
422
428
nc string
423
429
}{
424
- {"2 - 3" , ">= 2, <= 3" },
425
- {"2 - 3, 2 - 3" , ">= 2, <= 3,>= 2, <= 3" },
426
- {"2 - 3, 4.0.0 - 5.1" , ">= 2, <= 3,>= 4.0.0, <= 5.1" },
430
+ {"2 - 3" , ">= 2, <= 3 " },
431
+ {"2 - 3, 2 - 3" , ">= 2, <= 3 ,>= 2, <= 3 " },
432
+ {"2 - 3, 4.0.0 - 5.1" , ">= 2, <= 3 ,>= 4.0.0, <= 5.1 " },
433
+ {"2 - 3 4.0.0 - 5.1" , ">= 2, <= 3 >= 4.0.0, <= 5.1 " },
434
+ {"1.0.0 - 2.0.0 <=2.0.0" , ">= 1.0.0, <= 2.0.0 <=2.0.0" },
427
435
}
428
436
429
437
for _ , tc := range tests {
430
438
o := rewriteRange (tc .c )
431
439
432
440
if o != tc .nc {
433
- t .Errorf ("Range %s rewritten incorrectly as '%s' " , tc .c , o )
441
+ t .Errorf ("Range %s rewritten incorrectly as %q instead of expected %q " , tc .c , o , tc . nc )
434
442
}
435
443
}
436
444
}
0 commit comments