Search in sources :

Example 1 with Branch

use of com.jcabi.github.Branch in project jcabi-github by jcabi.

the class MkBranchesTest method createsBranch.

/**
 * MkBranches can create a new branch.
 * @throws IOException if there is any I/O problem
 */
@Test
public void createsBranch() throws IOException {
    final String name = "my-new-feature";
    final String sha = "590e188e3d52a8da38cf51d3f9bf598bb46911af";
    final Repo repo = new MkGithub().randomRepo();
    final Branch branch = ((MkBranches) (repo.branches())).create(name, sha);
    MatcherAssert.assertThat(branch.name(), Matchers.equalTo(name));
    MatcherAssert.assertThat(branch.commit().sha(), Matchers.equalTo(sha));
    final Coordinates coords = branch.commit().repo().coordinates();
    MatcherAssert.assertThat(coords.user(), Matchers.equalTo(repo.coordinates().user()));
    MatcherAssert.assertThat(coords.repo(), Matchers.equalTo(repo.coordinates().repo()));
}
Also used : Repo(com.jcabi.github.Repo) Branch(com.jcabi.github.Branch) Coordinates(com.jcabi.github.Coordinates) Test(org.junit.Test)

Example 2 with Branch

use of com.jcabi.github.Branch in project jcabi-github by jcabi.

the class MkBranchesTest method iteratesOverBranches.

/**
 * MkBranches can iterate over the repo's branches.
 * @throws IOException if there is any I/O problem
 */
@Test
public void iteratesOverBranches() throws IOException {
    final MkBranches branches = (MkBranches) (new MkGithub().randomRepo().branches());
    final String onename = "narf";
    final String onesha = "a86da33b875e8ecbaf75cefcf6d8957cbecb654e";
    branches.create(onename, onesha);
    final String twoname = "zort";
    final String twosha = "ba00fa4fe331c59736b87f52f760e1ccfb293b5f";
    branches.create(twoname, twosha);
    MatcherAssert.assertThat(branches.iterate(), Matchers.<Branch>iterableWithSize(2));
    final Iterator<Branch> iter = branches.iterate().iterator();
    final Branch one = iter.next();
    MatcherAssert.assertThat(one.name(), Matchers.equalTo(onename));
    MatcherAssert.assertThat(one.commit().sha(), Matchers.equalTo(onesha));
    final Branch two = iter.next();
    MatcherAssert.assertThat(two.name(), Matchers.equalTo(twoname));
    MatcherAssert.assertThat(two.commit().sha(), Matchers.equalTo(twosha));
}
Also used : Branch(com.jcabi.github.Branch) Test(org.junit.Test)

Aggregations

Branch (com.jcabi.github.Branch)2 Test (org.junit.Test)2 Coordinates (com.jcabi.github.Coordinates)1 Repo (com.jcabi.github.Repo)1