MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / v2_roundtrips_every_git_derivation

Function v2_roundtrips_every_git_derivation

atomic-core/src/change/change.rs:1611–1633  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1609
1610 #[test]
1611 fn v2_roundtrips_every_git_derivation() {
1612 use crate::change::GitDerivation;
1613
1614 let cases = [
1615 (GitDerivation::Root, Vec::new()),
1616 (GitDerivation::FirstParent, vec![sha1(2)]),
1617 (GitDerivation::MultiParent, vec![sha1(2), sha1(3)]),
1618 (GitDerivation::Squash, vec![sha1(2)]),
1619 (GitDerivation::EmptyCommit, Vec::new()),
1620 (GitDerivation::RewriteCandidate, vec![sha1(2)]),
1621 ];
1622
1623 for (derivation, parents) in cases {
1624 let origin = ChangeOrigin::git_synthesized(sha1(1), parents, derivation).unwrap();
1625 let change = Change::empty(ChangeHeader::new("derivation"))
1626 .with_classification(ChangeKind::Durable, None, origin, CausalFrontier::empty())
1627 .unwrap();
1628 let mut bytes = Vec::new();
1629 change.serialize(&mut bytes).unwrap();
1630 let (loaded, _) = Change::deserialize(&mut Cursor::new(&bytes)).unwrap();
1631 assert_eq!(loaded.origin(), change.origin());
1632 }
1633 }
1634
1635 #[test]
1636 fn v2_hashes_ordered_git_parents_and_derivation() {

Callers

nothing calls this directly

Calls 5

with_classificationMethod · 0.80
sha1Function · 0.70
deserializeFunction · 0.50
unwrapMethod · 0.45
serializeMethod · 0.45

Tested by

no test coverage detected