From 4e6323c0a4669d3c76a36ffb943a38970ff3e9de Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Wed, 6 Sep 2023 10:08:32 +0900 Subject: [PATCH] revset: add basic test for tag name resolution --- lib/tests/test_revset.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/lib/tests/test_revset.rs b/lib/tests/test_revset.rs index f49fc23ce..b525ced41 100644 --- a/lib/tests/test_revset.rs +++ b/lib/tests/test_revset.rs @@ -589,6 +589,39 @@ fn test_resolve_symbol_branches() { "###); } +#[test] +fn test_resolve_symbol_tags() { + let settings = testutils::user_settings(); + let test_repo = TestRepo::init(true); + let repo = &test_repo.repo; + + let mut tx = repo.start_transaction(&settings, "test"); + let mut_repo = tx.mut_repo(); + + let commit1 = write_random_commit(mut_repo, &settings); + let commit2 = write_random_commit(mut_repo, &settings); + let commit3 = write_random_commit(mut_repo, &settings); + + mut_repo.set_tag_target("tag-branch", RefTarget::normal(commit1.id().clone())); + mut_repo.set_local_branch_target("tag-branch", RefTarget::normal(commit2.id().clone())); + mut_repo.set_git_ref_target( + "refs/tags/unimported", + RefTarget::normal(commit3.id().clone()), + ); + + // Tag precedes branch + assert_eq!( + resolve_symbol(mut_repo, "tag-branch").unwrap(), + vec![commit1.id().clone()], + ); + + // TODO: remove refs/tags lookup + assert_eq!( + resolve_symbol(mut_repo, "unimported").unwrap(), + vec![commit3.id().clone()], + ); +} + #[test] fn test_resolve_symbol_git_head() { let settings = testutils::user_settings();