Search in sources :

Example 1 with RepoCommit

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

the class MkContentsTest method canRemoveFile.

/**
 * MkContents should be able to create new files.
 *
 * @throws Exception if some problem inside
 */
@Test
public void canRemoveFile() throws Exception {
    final Repo repo = new MkGithub().randomRepo();
    final String path = "removeme.txt";
    this.createFile(repo, path);
    final JsonObject json = MkContentsTest.content(path, "theDeleteMessage").add("committer", MkContentsTest.committer()).build();
    final RepoCommit commit = repo.contents().remove(json);
    MatcherAssert.assertThat(commit, Matchers.notNullValue());
    MatcherAssert.assertThat(commit.json().getString("message"), Matchers.equalTo("theDeleteMessage"));
}
Also used : Repo(com.jcabi.github.Repo) RepoCommit(com.jcabi.github.RepoCommit) JsonObject(javax.json.JsonObject) Test(org.junit.Test)

Example 2 with RepoCommit

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

the class MkContentsTest method canRemoveFileFromBranch.

/**
 * MkContents should be able to remove files from from non-default branches.
 *
 * @throws Exception if some problem inside
 */
@Test
public void canRemoveFileFromBranch() throws Exception {
    final String branch = "branch-1";
    final Repo repo = new MkGithub().randomRepo();
    final String path = "removeme.txt";
    this.createFile(repo, path);
    final JsonObject json = MkContentsTest.content(path, "theDeleteMessage").add("ref", branch).add("committer", MkContentsTest.committer()).build();
    final RepoCommit commit = repo.contents().remove(json);
    MatcherAssert.assertThat(commit, Matchers.notNullValue());
    MatcherAssert.assertThat(commit.json().getString("message"), Matchers.equalTo("theDeleteMessage"));
}
Also used : Repo(com.jcabi.github.Repo) RepoCommit(com.jcabi.github.RepoCommit) JsonObject(javax.json.JsonObject) Test(org.junit.Test)

Aggregations

Repo (com.jcabi.github.Repo)2 RepoCommit (com.jcabi.github.RepoCommit)2 JsonObject (javax.json.JsonObject)2 Test (org.junit.Test)2