@@ -7,29 +7,37 @@ fn baseline() {
77}
88
99mod invalid {
10- use git_refspec:: { parse, parse:: Error , Operation } ;
10+ use crate :: parse:: try_parse;
11+ use git_refspec:: { parse:: Error , Operation } ;
1112
1213 #[ test]
13- #[ ignore]
1414 fn empty ( ) {
15- assert ! ( matches!( parse ( "" . into ( ) , Operation :: Fetch ) . unwrap_err( ) , Error :: Empty ) ) ;
16- assert ! ( matches!( parse ( "" . into ( ) , Operation :: Push ) . unwrap_err( ) , Error :: Empty ) ) ;
15+ assert ! ( matches!( try_parse ( "" , Operation :: Fetch ) . unwrap_err( ) , Error :: Empty ) ) ;
16+ assert ! ( matches!( try_parse ( "" , Operation :: Push ) . unwrap_err( ) , Error :: Empty ) ) ;
1717 }
1818
1919 #[ test]
20- #[ ignore]
2120 fn negative_with_destination ( ) {
22- assert ! ( matches! (
23- parse ( "^a:b" . into ( ) , Operation :: Fetch ) . unwrap_err ( ) ,
24- Error :: NegativeWithDestination
25- ) ) ;
26- assert ! ( matches! (
27- parse ( "a:b" . into ( ) , Operation :: Fetch ) . unwrap_err ( ) ,
28- Error :: NegativeWithDestination
29- ) ) ;
21+ for op in [ Operation :: Fetch , Operation :: Push ] {
22+ for spec in [ "^a:b" , "^a:" , "^:" , "^:b" ] {
23+ assert ! ( matches! (
24+ try_parse ( spec , op ) . unwrap_err ( ) ,
25+ Error :: NegativeWithDestination
26+ ) ) ;
27+ }
28+ }
3029 }
3130
3231 mod fetch { }
3332
3433 mod push { }
3534}
35+
36+ mod util {
37+ use git_refspec:: { Operation , RefSpecRef } ;
38+
39+ pub fn try_parse ( spec : & str , op : Operation ) -> Result < RefSpecRef < ' _ > , git_refspec:: parse:: Error > {
40+ git_refspec:: parse ( spec. into ( ) , op)
41+ }
42+ }
43+ pub use util:: * ;
0 commit comments