ok/jj
1
0
Fork 0
forked from mirrors/jj

tests: make RefTarget::Conflict { .. } assertion not rely on id order

Here we don't need to care about the order at all. We have test_refs.rs
to ensure that the order is stable.
This commit is contained in:
Yuya Nishihara 2023-07-12 04:41:08 +09:00
parent 9f06bf8be5
commit ddaf226108

View file

@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
use itertools::Itertools as _;
use jj_lib::op_store::{RefTarget, WorkspaceId}; use jj_lib::op_store::{RefTarget, WorkspaceId};
use jj_lib::repo::Repo; use jj_lib::repo::Repo;
use jj_lib::repo_path::RepoPath; use jj_lib::repo_path::RepoPath;
@ -1139,16 +1140,20 @@ fn test_rebase_descendants_update_branches_after_divergent_rewrite() {
.write() .write()
.unwrap(); .unwrap();
tx.mut_repo().rebase_descendants(&settings).unwrap(); tx.mut_repo().rebase_descendants(&settings).unwrap();
let target = tx.mut_repo().get_local_branch("main").unwrap();
assert!(target.is_conflict());
assert_eq!( assert_eq!(
tx.mut_repo().get_local_branch("main"), target.removes().iter().counts(),
Some(RefTarget::Conflict { hashmap! { commit_b.id() => 2 },
removes: vec![commit_b.id().clone(), commit_b.id().clone()], );
adds: vec![ assert_eq!(
commit_b2.id().clone(), target.adds().iter().counts(),
commit_b3.id().clone(), hashmap! {
commit_b4.id().clone() commit_b2.id() => 1,
] commit_b3.id() => 1,
}) commit_b4.id() => 1,
},
); );
assert_eq!( assert_eq!(
@ -1210,16 +1215,20 @@ fn test_rebase_descendants_rewrite_updates_branch_conflict() {
.write() .write()
.unwrap(); .unwrap();
tx.mut_repo().rebase_descendants(&settings).unwrap(); tx.mut_repo().rebase_descendants(&settings).unwrap();
let target = tx.mut_repo().get_local_branch("main").unwrap();
assert!(target.is_conflict());
assert_eq!( assert_eq!(
tx.mut_repo().get_local_branch("main"), target.removes().iter().counts(),
Some(RefTarget::Conflict { hashmap! { commit_a.id() => 1, commit_b.id() => 1 },
removes: vec![commit_a.id().clone(), commit_b.id().clone()], );
adds: vec![ assert_eq!(
commit_c.id().clone(), target.adds().iter().counts(),
commit_b2.id().clone(), hashmap! {
commit_b3.id().clone(), commit_c.id() => 1,
] commit_b2.id() => 1,
}) commit_b3.id() => 1,
},
); );
assert_eq!( assert_eq!(