use of com.google.copybara.git.GerritDestination.GerritWriteHook in project copybara by google.
the class GerritDestinationTest method testProcesPushOutput.
private void testProcesPushOutput(boolean newReview, Type created, String gerritResponse, String expectedConsoleMessage) throws IOException, RepoException, ValidationException {
GerritWriteHook process = new GerritWriteHook(options.general, options.gerrit, "http://example.com/foo", new Author("foo", "foo@example.com"), ImmutableList.of(), ImmutableList.of(), ChangeIdPolicy.REPLACE, /*allowEmptyDiffPatchSet=*/
true, /*labels*/
ImmutableList.of(), /*endpointChecker=*/
null, /*notifyOption*/
null, /*topicTemplate*/
null, /*partialFetch*/
false, /*gerritSubmit*/
false, /*primaryBranchMigrationMode*/
false);
fakeOneCommitInDestination();
ImmutableList<DestinationEffect> result = process.afterPush(gerritResponse, new GerritMessageInfo(ImmutableList.of(), newReview, CONSTANT_CHANGE_ID), repo().resolveReference("HEAD"), Changes.EMPTY.getCurrent());
console.assertThat().onceInLog(MessageType.INFO, expectedConsoleMessage);
assertThat(result).hasSize(2);
assertThat(result.get(0).getErrors()).isEmpty();
assertThat(result.get(0).getType()).isEqualTo(Type.CREATED);
assertThat(result.get(0).getDestinationRef().getType()).isEqualTo("commit");
assertThat(result.get(0).getDestinationRef().getId()).matches("[0-9a-f]{40}");
assertThat(result.get(1).getSummary()).contains(expectedConsoleMessage);
assertThat(result.get(1).getType()).isEqualTo(created);
assertThat(result.get(1).getDestinationRef().getId()).isEqualTo("1234");
assertThat(result.get(1).getDestinationRef().getType()).isEqualTo("gerrit_review");
assertThat(result.get(1).getDestinationRef().getUrl()).isEqualTo("https://some.url.google.com/1234");
}
Aggregations