Search in sources :

Example 1 with Diff

use of org.projectnessie.versioned.Diff in project nessie by projectnessie.

the class AbstractDiff method checkDiff.

@Test
protected void checkDiff() throws VersionStoreException {
    final BranchName branch = BranchName.of("checkDiff");
    store().create(branch, Optional.empty());
    final Hash initial = store().hashOnReference(branch, Optional.empty());
    final Hash firstCommit = commit("First Commit").put("k1", V_1).put("k2", V_2).toBranch(branch);
    final Hash secondCommit = commit("Second Commit").put("k2", V_2_A).put("k3", V_3).toBranch(branch);
    List<Diff<BaseContent>> startToSecond = diffAsList(initial, secondCommit);
    assertThat(startToSecond).containsExactlyInAnyOrder(Diff.of(Key.of("k1"), Optional.empty(), Optional.of(V_1)), Diff.of(Key.of("k2"), Optional.empty(), Optional.of(V_2_A)), Diff.of(Key.of("k3"), Optional.empty(), Optional.of(V_3)));
    List<Diff<BaseContent>> secondToStart = diffAsList(secondCommit, initial);
    assertThat(secondToStart).containsExactlyInAnyOrder(Diff.of(Key.of("k1"), Optional.of(V_1), Optional.empty()), Diff.of(Key.of("k2"), Optional.of(V_2_A), Optional.empty()), Diff.of(Key.of("k3"), Optional.of(V_3), Optional.empty()));
    List<Diff<BaseContent>> firstToSecond = diffAsList(firstCommit, secondCommit);
    assertThat(firstToSecond).containsExactlyInAnyOrder(Diff.of(Key.of("k2"), Optional.of(V_2), Optional.of(V_2_A)), Diff.of(Key.of("k3"), Optional.empty(), Optional.of(V_3)));
    List<Diff<BaseContent>> firstToFirst = diffAsList(firstCommit, firstCommit);
    assertTrue(firstToFirst.isEmpty());
}
Also used : Diff(org.projectnessie.versioned.Diff) BranchName(org.projectnessie.versioned.BranchName) Hash(org.projectnessie.versioned.Hash) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)1 BranchName (org.projectnessie.versioned.BranchName)1 Diff (org.projectnessie.versioned.Diff)1 Hash (org.projectnessie.versioned.Hash)1