Skip to content

Commit

Permalink
tests: rewrite "@"/"root" revset resolution tests without using bad g…
Browse files Browse the repository at this point in the history
…it refs
  • Loading branch information
yuja committed Sep 10, 2023
1 parent 86206e8 commit b80d043
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions lib/tests/test_revset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,22 @@ fn test_resolve_symbol_tags() {
resolve_symbol(mut_repo, "unimported"),
Err(RevsetResolutionError::NoSuchRevision { .. })
);

// "@" (quoted) can be resolved, and root is a normal symbol.
let ws_id = WorkspaceId::default();
mut_repo
.set_wc_commit(ws_id.clone(), commit1.id().clone())
.unwrap();
mut_repo.set_tag_target("@", RefTarget::normal(commit2.id().clone()));
mut_repo.set_tag_target("root", RefTarget::normal(commit3.id().clone()));
assert_eq!(
resolve_symbol(mut_repo, r#""@""#).unwrap(),
vec![commit2.id().clone()]
);
assert_eq!(
resolve_symbol(mut_repo, "root").unwrap(),
vec![commit3.id().clone()]
);
}

#[test]
Expand Down Expand Up @@ -753,22 +769,6 @@ fn test_resolve_symbol_git_refs() {
Err(RevsetResolutionError::NoSuchRevision { .. })
);

// "@" (quoted) can be resolved, and root is a normal symbol.
let ws_id = WorkspaceId::default();
mut_repo
.set_wc_commit(ws_id.clone(), commit1.id().clone())
.unwrap();
mut_repo.set_git_ref_target("@", RefTarget::normal(commit2.id().clone()));
mut_repo.set_git_ref_target("root", RefTarget::normal(commit3.id().clone()));
assert_eq!(
resolve_symbol(mut_repo, r#""@""#).unwrap(),
vec![commit2.id().clone()]
);
assert_eq!(
resolve_symbol(mut_repo, "root").unwrap(),
vec![commit3.id().clone()]
);

// Conflicted ref resolves to its "adds"
assert_eq!(
resolve_symbol(mut_repo, "refs/heads/conflicted").unwrap(),
Expand Down

0 comments on commit b80d043

Please sign in to comment.