test: add assertions for contents of OpsetResolutionError::MultipleOperations

We don't want to derive `PartialEq` on `OpsetResolutionError` because we may need an
`Other` variant in the future that wraps a type without a `PartialEq` implementation.
Pattern-matching is used instead to assert the contents.
This commit is contained in:
Vincent Ging Ho Yim 2025-05-19 11:34:39 +10:00
parent c406b3a929
commit 3bb9f11dd5

View File

@ -588,19 +588,25 @@ fn test_resolve_op_parents_children() {
let tx1 = repo.start_transaction();
let tx2 = repo.start_transaction();
let repo = testutils::commit_transactions(vec![tx1, tx2]);
let parent_op_ids = repo.operation().parent_ids();
let op5_id_hex = repo.operation().id().hex();
let op_str = format!("{op5_id_hex}-");
assert_matches!(
op_walk::resolve_op_with_repo(&repo, &format!("{op5_id_hex}-")),
op_walk::resolve_op_with_repo(&repo, &op_str),
Err(OpsetEvaluationError::OpsetResolution(
OpsetResolutionError::MultipleOperations { .. }
OpsetResolutionError::MultipleOperations { expr, candidates }
))
if expr == *op_str && candidates == parent_op_ids
);
let op2_id_hex = operations[2].id().hex();
let op_str = format!("{op2_id_hex}+");
assert_matches!(
op_walk::resolve_op_with_repo(&repo, &format!("{op2_id_hex}+")),
op_walk::resolve_op_with_repo(&repo, &op_str),
Err(OpsetEvaluationError::OpsetResolution(
OpsetResolutionError::MultipleOperations { .. }
OpsetResolutionError::MultipleOperations { expr, candidates }
))
if expr == *op_str && candidates == parent_op_ids
);
}