use of com.virtuslab.gitmachete.backend.api.RelationToRemote in project git-machete-intellij-plugin by VirtusLab.
the class GitMacheteRepository_deriveRelationToRemoteUnitTestSuite method deriveRelationToRemote_DivergedAndNewerThan.
@Test
@SneakyThrows
public void deriveRelationToRemote_DivergedAndNewerThan() {
// given
PowerMockito.doReturn(List.of(ORIGIN)).when(gitCoreRepository).deriveAllRemoteNames();
PowerMockito.doReturn(Option.some(coreRemoteBranch)).when(coreLocalBranch).getRemoteTrackingBranch();
PowerMockito.doReturn(coreLocalBranchCommit).when(coreLocalBranch).getPointedCommit();
PowerMockito.doReturn(coreRemoteBranchCommit).when(coreRemoteBranch).getPointedCommit();
val relativeCommitCount = GitCoreRelativeCommitCount.of(1, 1);
PowerMockito.doReturn(Option.some(relativeCommitCount)).when(gitCoreRepository).deriveRelativeCommitCount(coreLocalBranchCommit, coreRemoteBranchCommit);
Instant newerInstant = Instant.parse("2000-05-01T10:00:00Z");
Instant olderInstant = newerInstant.minus(10, ChronoUnit.MINUTES);
PowerMockito.doReturn(newerInstant).when(coreLocalBranchCommit).getCommitTime();
PowerMockito.doReturn(olderInstant).when(coreRemoteBranchCommit).getCommitTime();
// when
RelationToRemote relationToRemote = invokeDeriveRelationToRemote(coreLocalBranch);
// then
Assert.assertEquals(SyncToRemoteStatus.DivergedFromAndNewerThanRemote, relationToRemote.getSyncToRemoteStatus());
}
use of com.virtuslab.gitmachete.backend.api.RelationToRemote in project git-machete-intellij-plugin by VirtusLab.
the class GitMacheteRepository_deriveRelationToRemoteUnitTestSuite method deriveRelationToRemote_NoRemotes.
@Test
@SneakyThrows
public void deriveRelationToRemote_NoRemotes() {
// given
PowerMockito.doReturn(List.empty()).when(gitCoreRepository).deriveAllRemoteNames();
// when
RelationToRemote relationToRemote = invokeDeriveRelationToRemote(coreLocalBranch);
// then
Assert.assertEquals(SyncToRemoteStatus.NoRemotes, relationToRemote.getSyncToRemoteStatus());
}
use of com.virtuslab.gitmachete.backend.api.RelationToRemote in project git-machete-intellij-plugin by VirtusLab.
the class GitMacheteRepository_deriveRelationToRemoteUnitTestSuite method deriveRelationToRemote_Ahead.
@Test
@SneakyThrows
public void deriveRelationToRemote_Ahead() {
// given
PowerMockito.doReturn(List.of(ORIGIN)).when(gitCoreRepository).deriveAllRemoteNames();
PowerMockito.doReturn(Option.some(coreRemoteBranch)).when(coreLocalBranch).getRemoteTrackingBranch();
PowerMockito.doReturn(coreLocalBranchCommit).when(coreLocalBranch).getPointedCommit();
PowerMockito.doReturn(coreRemoteBranchCommit).when(coreRemoteBranch).getPointedCommit();
val relativeCommitCount = GitCoreRelativeCommitCount.of(3, 0);
PowerMockito.doReturn(Option.some(relativeCommitCount)).when(gitCoreRepository).deriveRelativeCommitCount(coreLocalBranchCommit, coreRemoteBranchCommit);
// when
RelationToRemote relationToRemote = invokeDeriveRelationToRemote(coreLocalBranch);
// then
Assert.assertEquals(SyncToRemoteStatus.AheadOfRemote, relationToRemote.getSyncToRemoteStatus());
}
use of com.virtuslab.gitmachete.backend.api.RelationToRemote in project git-machete-intellij-plugin by VirtusLab.
the class GitMacheteRepository_deriveRelationToRemoteUnitTestSuite method deriveRelationToRemote_Behind.
@Test
@SneakyThrows
public void deriveRelationToRemote_Behind() {
// given
PowerMockito.doReturn(List.of(ORIGIN)).when(gitCoreRepository).deriveAllRemoteNames();
PowerMockito.doReturn(Option.some(coreRemoteBranch)).when(coreLocalBranch).getRemoteTrackingBranch();
PowerMockito.doReturn(coreLocalBranchCommit).when(coreLocalBranch).getPointedCommit();
PowerMockito.doReturn(coreRemoteBranchCommit).when(coreRemoteBranch).getPointedCommit();
val relativeCommitCount = GitCoreRelativeCommitCount.of(0, 3);
PowerMockito.doReturn(Option.some(relativeCommitCount)).when(gitCoreRepository).deriveRelativeCommitCount(coreLocalBranchCommit, coreRemoteBranchCommit);
// when
RelationToRemote relationToRemote = invokeDeriveRelationToRemote(coreLocalBranch);
// then
Assert.assertEquals(SyncToRemoteStatus.BehindRemote, relationToRemote.getSyncToRemoteStatus());
}
use of com.virtuslab.gitmachete.backend.api.RelationToRemote in project git-machete-intellij-plugin by VirtusLab.
the class GitMacheteRepository_deriveRelationToRemoteUnitTestSuite method deriveRelationToRemote_Untracked.
@Test
@SneakyThrows
public void deriveRelationToRemote_Untracked() {
// given
PowerMockito.doReturn(List.of(ORIGIN)).when(gitCoreRepository).deriveAllRemoteNames();
PowerMockito.doReturn(Option.none()).when(coreLocalBranch).getRemoteTrackingBranch();
// when
RelationToRemote relationToRemote = invokeDeriveRelationToRemote(coreLocalBranch);
// then
Assert.assertEquals(SyncToRemoteStatus.Untracked, relationToRemote.getSyncToRemoteStatus());
}
Aggregations