Search in sources :

Example 1 with SyncToParentStatus

use of com.virtuslab.gitmachete.backend.api.SyncToParentStatus in project git-machete-intellij-plugin by VirtusLab.

the class GitMacheteRepository_deriveSyncToParentStatusUnitTestSuite method branchAndParentPointingSameCommitAndBranchNotJustCreated_merged.

@Test
public void branchAndParentPointingSameCommitAndBranchNotJustCreated_merged() {
    // given
    IGitCoreCommit commit = createGitCoreCommit();
    IGitCoreLocalBranchSnapshot parentBranch = createGitCoreLocalBranch(commit);
    IGitCoreLocalBranchSnapshot childBranch = createGitCoreLocalBranch(commit, new TestGitCoreReflogEntry());
    // when
    SyncToParentStatus syncToParentStatus = invokeDeriveSyncToParentStatus(childBranch, parentBranch, MISSING_FORK_POINT);
    // then
    Assert.assertEquals(SyncToParentStatus.MergedToParent, syncToParentStatus);
}
Also used : TestGitCoreReflogEntry(com.virtuslab.gitmachete.backend.unit.UnitTestUtils.TestGitCoreReflogEntry) IGitCoreCommit(com.virtuslab.gitcore.api.IGitCoreCommit) SyncToParentStatus(com.virtuslab.gitmachete.backend.api.SyncToParentStatus) IGitCoreLocalBranchSnapshot(com.virtuslab.gitcore.api.IGitCoreLocalBranchSnapshot) Test(org.junit.Test)

Example 2 with SyncToParentStatus

use of com.virtuslab.gitmachete.backend.api.SyncToParentStatus in project git-machete-intellij-plugin by VirtusLab.

the class GitMacheteRepository_deriveSyncToParentStatusUnitTestSuite method branchPointedCommitIsAncestorOfParentPointedCommit_merged.

@Test
@SneakyThrows
public void branchPointedCommitIsAncestorOfParentPointedCommit_merged() {
    // given
    IGitCoreCommit childCommit = createGitCoreCommit();
    IGitCoreCommit parentCommit = createGitCoreCommit();
    IGitCoreLocalBranchSnapshot childBranch = createGitCoreLocalBranch(childCommit);
    IGitCoreLocalBranchSnapshot parentBranch = createGitCoreLocalBranch(parentCommit);
    PowerMockito.doReturn(false).when(gitCoreRepository).isAncestorOrEqual(parentCommit, childCommit);
    PowerMockito.doReturn(true).when(gitCoreRepository).isAncestorOrEqual(childCommit, parentCommit);
    // when
    SyncToParentStatus syncToParentStatus = invokeDeriveSyncToParentStatus(childBranch, parentBranch, MISSING_FORK_POINT);
    // then
    Assert.assertEquals(SyncToParentStatus.OutOfSync, syncToParentStatus);
}
Also used : IGitCoreCommit(com.virtuslab.gitcore.api.IGitCoreCommit) SyncToParentStatus(com.virtuslab.gitmachete.backend.api.SyncToParentStatus) IGitCoreLocalBranchSnapshot(com.virtuslab.gitcore.api.IGitCoreLocalBranchSnapshot) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 3 with SyncToParentStatus

use of com.virtuslab.gitmachete.backend.api.SyncToParentStatus in project git-machete-intellij-plugin by VirtusLab.

the class GitMacheteRepository_deriveSyncToParentStatusUnitTestSuite method branchAndParentPointingSameCommitAndBranchJustCreated_inSync.

@Test
public void branchAndParentPointingSameCommitAndBranchJustCreated_inSync() {
    // given
    IGitCoreCommit commit = createGitCoreCommit();
    IGitCoreLocalBranchSnapshot parentBranch = createGitCoreLocalBranch(commit);
    IGitCoreLocalBranchSnapshot childBranch = createGitCoreLocalBranch(commit);
    // when
    SyncToParentStatus syncToParentStatus = invokeDeriveSyncToParentStatus(childBranch, parentBranch, MISSING_FORK_POINT);
    // then
    Assert.assertEquals(SyncToParentStatus.InSync, syncToParentStatus);
}
Also used : IGitCoreCommit(com.virtuslab.gitcore.api.IGitCoreCommit) SyncToParentStatus(com.virtuslab.gitmachete.backend.api.SyncToParentStatus) IGitCoreLocalBranchSnapshot(com.virtuslab.gitcore.api.IGitCoreLocalBranchSnapshot) Test(org.junit.Test)

Example 4 with SyncToParentStatus

use of com.virtuslab.gitmachete.backend.api.SyncToParentStatus in project git-machete-intellij-plugin by VirtusLab.

the class GitMacheteRepository_deriveSyncToParentStatusUnitTestSuite method neitherBranchPointedCommitIsAncestorOfParentPointedCommitNorTheOtherWay_outOfSync.

@Test
@SneakyThrows
public void neitherBranchPointedCommitIsAncestorOfParentPointedCommitNorTheOtherWay_outOfSync() {
    // given
    IGitCoreCommit parentCommit = createGitCoreCommit();
    IGitCoreCommit childCommit = createGitCoreCommit();
    IGitCoreLocalBranchSnapshot parentBranch = createGitCoreLocalBranch(parentCommit);
    IGitCoreLocalBranchSnapshot childBranch = createGitCoreLocalBranch(childCommit);
    PowerMockito.doReturn(false).when(gitCoreRepository).isAncestorOrEqual(parentCommit, childCommit);
    PowerMockito.doReturn(false).when(gitCoreRepository).isAncestorOrEqual(childCommit, parentCommit);
    // when
    SyncToParentStatus syncToParentStatus = invokeDeriveSyncToParentStatus(childBranch, parentBranch, MISSING_FORK_POINT);
    // then
    Assert.assertEquals(SyncToParentStatus.OutOfSync, syncToParentStatus);
}
Also used : IGitCoreCommit(com.virtuslab.gitcore.api.IGitCoreCommit) SyncToParentStatus(com.virtuslab.gitmachete.backend.api.SyncToParentStatus) IGitCoreLocalBranchSnapshot(com.virtuslab.gitcore.api.IGitCoreLocalBranchSnapshot) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 5 with SyncToParentStatus

use of com.virtuslab.gitmachete.backend.api.SyncToParentStatus in project git-machete-intellij-plugin by VirtusLab.

the class GitMacheteRepository_deriveSyncToParentStatusUnitTestSuite method parentPointedCommitIsAncestorOfBranchPointedCommitButNotItsForkPoint_inSyncButOffForkPoint.

@Test
@SneakyThrows
public void parentPointedCommitIsAncestorOfBranchPointedCommitButNotItsForkPoint_inSyncButOffForkPoint() {
    // given
    IGitCoreCommit forkPointCommit = createGitCoreCommit();
    IGitCoreCommit parentCommit = createGitCoreCommit();
    IGitCoreCommit childCommit = createGitCoreCommit();
    IGitCoreLocalBranchSnapshot parentBranch = createGitCoreLocalBranch(parentCommit);
    IGitCoreLocalBranchSnapshot childBranch = createGitCoreLocalBranch(childCommit);
    PowerMockito.doReturn(true).when(gitCoreRepository).isAncestorOrEqual(parentCommit, childCommit);
    // when
    SyncToParentStatus syncToParentStatus = invokeDeriveSyncToParentStatus(childBranch, parentBranch, forkPointCommit);
    // then
    Assert.assertEquals(SyncToParentStatus.InSyncButForkPointOff, syncToParentStatus);
}
Also used : IGitCoreCommit(com.virtuslab.gitcore.api.IGitCoreCommit) SyncToParentStatus(com.virtuslab.gitmachete.backend.api.SyncToParentStatus) IGitCoreLocalBranchSnapshot(com.virtuslab.gitcore.api.IGitCoreLocalBranchSnapshot) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Aggregations

IGitCoreCommit (com.virtuslab.gitcore.api.IGitCoreCommit)6 IGitCoreLocalBranchSnapshot (com.virtuslab.gitcore.api.IGitCoreLocalBranchSnapshot)6 SyncToParentStatus (com.virtuslab.gitmachete.backend.api.SyncToParentStatus)6 Test (org.junit.Test)6 SneakyThrows (lombok.SneakyThrows)4 TestGitCoreReflogEntry (com.virtuslab.gitmachete.backend.unit.UnitTestUtils.TestGitCoreReflogEntry)1