Commit f3881bda authored by Greg Messner's avatar Greg Messner
Browse files

Added test for revertCommit() (#355).

parent 13a63bb7
...@@ -2,6 +2,7 @@ package org.gitlab4j.api; ...@@ -2,6 +2,7 @@ package org.gitlab4j.api;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
...@@ -287,4 +288,37 @@ public class TestCommitsApi extends AbstractIntegrationTest { ...@@ -287,4 +288,37 @@ public class TestCommitsApi extends AbstractIntegrationTest {
} catch (GitLabApiException ignore) { } catch (GitLabApiException ignore) {
} }
} }
@Test
public void testRevertCommit() throws GitLabApiException {
// Make sure the file to create does not exist.
String filePath = TEST_CREATE_COMMIT_FILEPATH + ".test";
if (gitLabApi.getRepositoryFileApi().getOptionalFile(testProject, filePath, "master").isPresent()) {
gitLabApi.getRepositoryFileApi().deleteFile(testProject, filePath, "master", "Deleted test file");
}
// Arrange
CommitAction commitAction = new CommitAction()
.withAction(Action.CREATE)
.withContent("This is the original data in the file")
.withFilePath(filePath);
// Act
Commit commit = gitLabApi.getCommitsApi().createCommit(
testProject, "master", "Testing createCommit() create action", null, null, null, commitAction);
// Assert
assertNotNull(commit);
Optional<RepositoryFile> repoFile = gitLabApi.getRepositoryFileApi().getOptionalFile(testProject, filePath, "master");
assertTrue(repoFile.isPresent());
// Act
Commit revertedCommit = gitLabApi.getCommitsApi().revertCommit(testProject, commit.getId(), "master");
// Assert
assertNotEquals(commit.getId(), revertedCommit.getId());
repoFile = gitLabApi.getRepositoryFileApi().getOptionalFile(testProject, filePath, "master");
assertFalse(repoFile.isPresent());
}
} }
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment