@@ -427,6 +427,98 @@ mod tests {
427
427
} ,
428
428
"foo@1.2" ,
429
429
) ;
430
+
431
+ // pkgid-spec.md
432
+ ok (
433
+ "regex" ,
434
+ PackageIdSpec {
435
+ name : String :: from ( "regex" ) ,
436
+ version : None ,
437
+ url : None ,
438
+ } ,
439
+ "regex" ,
440
+ ) ;
441
+ ok (
442
+ "regex@1.4" ,
443
+ PackageIdSpec {
444
+ name : String :: from ( "regex" ) ,
445
+ version : Some ( "1.4" . parse ( ) . unwrap ( ) ) ,
446
+ url : None ,
447
+ } ,
448
+ "regex@1.4" ,
449
+ ) ;
450
+ ok (
451
+ "regex@1.4.3" ,
452
+ PackageIdSpec {
453
+ name : String :: from ( "regex" ) ,
454
+ version : Some ( "1.4.3" . parse ( ) . unwrap ( ) ) ,
455
+ url : None ,
456
+ } ,
457
+ "regex@1.4.3" ,
458
+ ) ;
459
+ ok (
460
+ "https://github.com/rust-lang/crates.io-index#regex" ,
461
+ PackageIdSpec {
462
+ name : String :: from ( "regex" ) ,
463
+ version : None ,
464
+ url : Some ( Url :: parse ( "https://github.com/rust-lang/crates.io-index" ) . unwrap ( ) ) ,
465
+ } ,
466
+ "https://github.com/rust-lang/crates.io-index#regex" ,
467
+ ) ;
468
+ ok (
469
+ "https://github.com/rust-lang/crates.io-index#regex@1.4.3" ,
470
+ PackageIdSpec {
471
+ name : String :: from ( "regex" ) ,
472
+ version : Some ( "1.4.3" . parse ( ) . unwrap ( ) ) ,
473
+ url : Some ( Url :: parse ( "https://github.com/rust-lang/crates.io-index" ) . unwrap ( ) ) ,
474
+ } ,
475
+ "https://github.com/rust-lang/crates.io-index#regex@1.4.3" ,
476
+ ) ;
477
+ ok (
478
+ "https://github.com/rust-lang/cargo#0.52.0" ,
479
+ PackageIdSpec {
480
+ name : String :: from ( "cargo" ) ,
481
+ version : Some ( "0.52.0" . parse ( ) . unwrap ( ) ) ,
482
+ url : Some ( Url :: parse ( "https://github.com/rust-lang/cargo" ) . unwrap ( ) ) ,
483
+ } ,
484
+ "https://github.com/rust-lang/cargo#0.52.0" ,
485
+ ) ;
486
+ ok (
487
+ "https://github.com/rust-lang/cargo#cargo-platform@0.1.2" ,
488
+ PackageIdSpec {
489
+ name : String :: from ( "cargo-platform" ) ,
490
+ version : Some ( "0.1.2" . parse ( ) . unwrap ( ) ) ,
491
+ url : Some ( Url :: parse ( "https://github.com/rust-lang/cargo" ) . unwrap ( ) ) ,
492
+ } ,
493
+ "https://github.com/rust-lang/cargo#cargo-platform@0.1.2" ,
494
+ ) ;
495
+ ok (
496
+ "ssh://git@github.com/rust-lang/regex.git#regex@1.4.3" ,
497
+ PackageIdSpec {
498
+ name : String :: from ( "regex" ) ,
499
+ version : Some ( "1.4.3" . parse ( ) . unwrap ( ) ) ,
500
+ url : Some ( Url :: parse ( "ssh://git@github.com/rust-lang/regex.git" ) . unwrap ( ) ) ,
501
+ } ,
502
+ "ssh://git@github.com/rust-lang/regex.git#regex@1.4.3" ,
503
+ ) ;
504
+ ok (
505
+ "file:///path/to/my/project/foo" ,
506
+ PackageIdSpec {
507
+ name : String :: from ( "foo" ) ,
508
+ version : None ,
509
+ url : Some ( Url :: parse ( "file:///path/to/my/project/foo" ) . unwrap ( ) ) ,
510
+ } ,
511
+ "file:///path/to/my/project/foo" ,
512
+ ) ;
513
+ ok (
514
+ "file:///path/to/my/project/foo#1.1.8" ,
515
+ PackageIdSpec {
516
+ name : String :: from ( "foo" ) ,
517
+ version : Some ( "1.1.8" . parse ( ) . unwrap ( ) ) ,
518
+ url : Some ( Url :: parse ( "file:///path/to/my/project/foo" ) . unwrap ( ) ) ,
519
+ } ,
520
+ "file:///path/to/my/project/foo#1.1.8" ,
521
+ ) ;
430
522
}
431
523
432
524
#[ test]
0 commit comments