|
| 1 | +use crate::parse::{assert_parse, b, try_parse}; |
1 | 2 | use gix_refspec::{ |
2 | 3 | instruction::Push, |
3 | 4 | parse::{Error, Operation}, |
4 | 5 | Instruction, |
5 | 6 | }; |
6 | 7 |
|
7 | | -use crate::parse::{assert_parse, b, try_parse}; |
| 8 | +#[test] |
| 9 | +fn negative_must_not_be_empty() { |
| 10 | + assert!(matches!( |
| 11 | + try_parse("^", Operation::Push).unwrap_err(), |
| 12 | + Error::NegativeEmpty |
| 13 | + )); |
| 14 | +} |
| 15 | + |
| 16 | +#[test] |
| 17 | +fn negative_must_not_be_object_hash() { |
| 18 | + assert!(matches!( |
| 19 | + try_parse("^e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", Operation::Push).unwrap_err(), |
| 20 | + Error::NegativeObjectHash |
| 21 | + )); |
| 22 | +} |
8 | 23 |
|
9 | 24 | #[test] |
10 | | -fn negative_unsupported() { |
11 | | - for spec in ["^a:b", "^a:", "^:", "^:b", "^"] { |
| 25 | +fn negative_with_destination() { |
| 26 | + for spec in ["^a:b", "^a:", "^:", "^:b"] { |
12 | 27 | assert!(matches!( |
13 | 28 | try_parse(spec, Operation::Push).unwrap_err(), |
14 | | - Error::NegativeUnsupported |
| 29 | + Error::NegativeWithDestination |
15 | 30 | )); |
16 | 31 | } |
17 | 32 | } |
18 | 33 |
|
| 34 | +#[test] |
| 35 | +fn exclude() { |
| 36 | + assert!(matches!( |
| 37 | + try_parse("^a", Operation::Push).unwrap_err(), |
| 38 | + Error::NegativePartialName |
| 39 | + )); |
| 40 | + assert!(matches!( |
| 41 | + try_parse("^a*", Operation::Push).unwrap_err(), |
| 42 | + Error::NegativeGlobPattern |
| 43 | + )); |
| 44 | + assert_parse( |
| 45 | + "^refs/heads/a", |
| 46 | + Instruction::Push(Push::Exclude { src: b("refs/heads/a") }), |
| 47 | + ); |
| 48 | +} |
| 49 | + |
19 | 50 | #[test] |
20 | 51 | fn revspecs_with_ref_name_destination() { |
21 | 52 | assert_parse( |
|
0 commit comments