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.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
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.errors.GitAPIException;
|
||||
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.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
@ -19,9 +18,6 @@ import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public class CommandUnitTest {
|
||||
|
||||
private final static CredentialsProvider gitCreds = new UsernamePasswordCredentialsProvider(
|
||||
System.getProperty("git.username"), System.getProperty("git.token"));
|
||||
|
||||
private static File tmpdir;
|
||||
private static Git git;
|
||||
@ -31,8 +27,7 @@ public class CommandUnitTest {
|
||||
tmpdir = new File(System.getProperty("java.io.tmpdir"), "git-" + UUID.randomUUID().toString() + ".tmp");
|
||||
|
||||
git = new CloneCommand()
|
||||
.setURI("git@github.com:bmlong137/env-docker-adbp.git")
|
||||
.setCredentialsProvider(gitCreds)
|
||||
.setURI("git@bitbucket.org:inteligr8/git-utils.git")
|
||||
.setDirectory(tmpdir)
|
||||
.call();
|
||||
}
|
||||
@ -45,10 +40,17 @@ public class CommandUnitTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lotsOfBranches() throws GitAPIException {
|
||||
public void listOfBranches() throws GitAPIException, IOException {
|
||||
List<Ref> remoteBranches = git.branchList().setListMode(ListMode.REMOTE).call();
|
||||
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