Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
f3881bda
Commit
f3881bda
authored
May 15, 2019
by
Greg Messner
Browse files
Added test for revertCommit() (#355).
parent
13a63bb7
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/test/java/org/gitlab4j/api/TestCommitsApi.java
View file @
f3881bda
...
@@ -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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment