|
1 | 1 | mod single { |
2 | 2 | use crate::matching::baseline; |
3 | 3 |
|
| 4 | + fn test_hashes() -> (String, String) { |
| 5 | + let annotated_tag = match gix_testtools::hash_kind_from_env().unwrap_or_default() { |
| 6 | + gix_hash::Kind::Sha1 => "78b1c1be9421b33a49a7a8176d93eeeafa112da1", |
| 7 | + gix_hash::Kind::Sha256 => "b071221ea854da2958fba3a37527ca5cf32c4ebcd71ab0b68b6b8f10f04e93ad", |
| 8 | + _ => unimplemented!(), |
| 9 | + }; |
| 10 | + let initial_commit = match gix_testtools::hash_kind_from_env().unwrap_or_default() { |
| 11 | + gix_hash::Kind::Sha1 => "9d2fab1a0ba3585d0bc50922bfdd04ebb59361df", |
| 12 | + gix_hash::Kind::Sha256 => "ac050883b75422e0d03bfee760c591b292cbc10cee8ad934480ea5fb2ebc44fe", |
| 13 | + _ => unimplemented!(), |
| 14 | + }; |
| 15 | + |
| 16 | + (annotated_tag.into(), initial_commit.into()) |
| 17 | + } |
| 18 | + |
4 | 19 | #[test] |
5 | 20 | fn fetch_only() { |
| 21 | + let (annotated_tag, initial_commit) = test_hashes(); |
| 22 | + |
6 | 23 | baseline::agrees_with_fetch_specs(Some("refs/heads/main")); |
7 | 24 | baseline::agrees_with_fetch_specs(Some("heads/main")); |
8 | 25 | baseline::agrees_with_fetch_specs(Some("main")); |
9 | 26 | baseline::agrees_with_fetch_specs(Some("v0.0-f1")); |
10 | 27 | baseline::agrees_with_fetch_specs(Some("tags/v0.0-f2")); |
11 | | - baseline::of_objects_always_matches_if_the_server_has_the_object(Some( |
12 | | - "78b1c1be9421b33a49a7a8176d93eeeafa112da1", |
13 | | - )); |
14 | | - baseline::of_objects_always_matches_if_the_server_has_the_object(Some( |
15 | | - "9d2fab1a0ba3585d0bc50922bfdd04ebb59361df", |
16 | | - )); |
| 28 | + baseline::of_objects_always_matches_if_the_server_has_the_object(Some(annotated_tag.as_ref())); |
| 29 | + baseline::of_objects_always_matches_if_the_server_has_the_object(Some(initial_commit.as_ref())); |
17 | 30 | } |
18 | 31 |
|
19 | 32 | #[test] |
20 | 33 | fn fetch_and_update() { |
| 34 | + let (annotated_tag, initial_commit) = test_hashes(); |
| 35 | + |
21 | 36 | baseline::of_objects_with_destinations_are_written_into_given_local_branches( |
22 | | - Some("78b1c1be9421b33a49a7a8176d93eeeafa112da1:special"), |
23 | | - ["78b1c1be9421b33a49a7a8176d93eeeafa112da1:refs/heads/special"], |
| 37 | + Some(format!("{annotated_tag}:special").as_ref()), |
| 38 | + [format!("{annotated_tag}:refs/heads/special").as_ref()], |
24 | 39 | ); |
25 | 40 | baseline::of_objects_with_destinations_are_written_into_given_local_branches( |
26 | | - Some("78b1c1be9421b33a49a7a8176d93eeeafa112da1:1111111111111111111111111111111111111111"), |
27 | | - ["78b1c1be9421b33a49a7a8176d93eeeafa112da1:refs/heads/1111111111111111111111111111111111111111"], |
| 41 | + Some(format!("{annotated_tag}:1111111111111111111111111111111111111111").as_ref()), |
| 42 | + [format!("{annotated_tag}:refs/heads/1111111111111111111111111111111111111111").as_ref()], |
28 | 43 | ); |
29 | 44 | baseline::of_objects_with_destinations_are_written_into_given_local_branches( |
30 | | - Some("9d2fab1a0ba3585d0bc50922bfdd04ebb59361df:tags/special"), |
31 | | - ["9d2fab1a0ba3585d0bc50922bfdd04ebb59361df:refs/tags/special"], |
| 45 | + Some(format!("{initial_commit}:tags/special").as_ref()), |
| 46 | + [format!("{initial_commit}:refs/tags/special").as_ref()], |
32 | 47 | ); |
33 | 48 | baseline::of_objects_with_destinations_are_written_into_given_local_branches( |
34 | | - Some("9d2fab1a0ba3585d0bc50922bfdd04ebb59361df:refs/tags/special"), |
35 | | - ["9d2fab1a0ba3585d0bc50922bfdd04ebb59361df:refs/tags/special"], |
| 49 | + Some(format!("{initial_commit}:refs/tags/special").as_ref()), |
| 50 | + [format!("{initial_commit}:refs/tags/special").as_ref()], |
36 | 51 | ); |
37 | 52 |
|
38 | 53 | baseline::agrees_but_observable_refs_are_vague(Some("f1:origin/f1"), ["refs/heads/f1:refs/heads/origin/f1"]); |
|
0 commit comments