updated command test; ready for more tests in the future
This commit is contained in:
parent
909fde9477
commit
06db1d5d45
@ -2,6 +2,7 @@ package com.inteligr8.git;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -10,8 +11,6 @@ import org.eclipse.jgit.api.Git;
|
|||||||
import org.eclipse.jgit.api.ListBranchCommand.ListMode;
|
import org.eclipse.jgit.api.ListBranchCommand.ListMode;
|
||||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||||
import org.eclipse.jgit.lib.Ref;
|
import org.eclipse.jgit.lib.Ref;
|
||||||
import org.eclipse.jgit.transport.CredentialsProvider;
|
|
||||||
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
|
|
||||||
import org.eclipse.jgit.util.FileUtils;
|
import org.eclipse.jgit.util.FileUtils;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
@ -19,9 +18,6 @@ import org.junit.BeforeClass;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class CommandUnitTest {
|
public class CommandUnitTest {
|
||||||
|
|
||||||
private final static CredentialsProvider gitCreds = new UsernamePasswordCredentialsProvider(
|
|
||||||
System.getProperty("git.username"), System.getProperty("git.token"));
|
|
||||||
|
|
||||||
private static File tmpdir;
|
private static File tmpdir;
|
||||||
private static Git git;
|
private static Git git;
|
||||||
@ -31,8 +27,7 @@ public class CommandUnitTest {
|
|||||||
tmpdir = new File(System.getProperty("java.io.tmpdir"), "git-" + UUID.randomUUID().toString() + ".tmp");
|
tmpdir = new File(System.getProperty("java.io.tmpdir"), "git-" + UUID.randomUUID().toString() + ".tmp");
|
||||||
|
|
||||||
git = new CloneCommand()
|
git = new CloneCommand()
|
||||||
.setURI("git@github.com:bmlong137/env-docker-adbp.git")
|
.setURI("git@bitbucket.org:inteligr8/git-utils.git")
|
||||||
.setCredentialsProvider(gitCreds)
|
|
||||||
.setDirectory(tmpdir)
|
.setDirectory(tmpdir)
|
||||||
.call();
|
.call();
|
||||||
}
|
}
|
||||||
@ -45,10 +40,17 @@ public class CommandUnitTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void lotsOfBranches() throws GitAPIException {
|
public void listOfBranches() throws GitAPIException, IOException {
|
||||||
List<Ref> remoteBranches = git.branchList().setListMode(ListMode.REMOTE).call();
|
List<Ref> remoteBranches = git.branchList().setListMode(ListMode.REMOTE).call();
|
||||||
Assert.assertNotNull(remoteBranches);
|
Assert.assertNotNull(remoteBranches);
|
||||||
Assert.assertTrue(remoteBranches.size() > 5);
|
Assert.assertTrue(remoteBranches.contains(git.getRepository().findRef("origin/develop")));
|
||||||
|
Assert.assertTrue(remoteBranches.contains(git.getRepository().findRef("origin/stable")));
|
||||||
|
|
||||||
|
List<Ref> localBranches = git.branchList().call();
|
||||||
|
Assert.assertNotNull(localBranches);
|
||||||
|
Assert.assertEquals(1, localBranches.size());
|
||||||
|
|
||||||
|
Assert.assertTrue(Collections.disjoint(remoteBranches, localBranches));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user