use of com.google.copybara.feedback.Feedback in project copybara by google.
the class FeedbackTest method testAction.
@Test
public void testAction() throws Exception {
Feedback feedback = loggingFeedback();
feedback.run(workdir, ImmutableList.of("12345"));
console.assertThat().onceInLog(MessageType.INFO, "Ref: 12345");
console.assertThat().onceInLog(MessageType.INFO, "Feedback name: default");
console.assertThat().onceInLog(MessageType.INFO, "Action name: test_action");
}
use of com.google.copybara.feedback.Feedback in project copybara by google.
the class FeedbackTest method runAndVerifyDestinationEffects.
private void runAndVerifyDestinationEffects(String actionsCode, ImmutableList<String> expectedErrors, String expectedSummary, String expectedOriginRef, String expectedDestRef, String expectedDestType, @Nullable String expectedDestUrl) throws IOException, ValidationException, RepoException {
Feedback feedback = feedback(actionsCode, "test_action");
feedback.run(workdir, ImmutableList.of());
console.assertThat().equalsNext(MessageType.INFO, "Action 'test_action' returned success");
assertThat(eventMonitor.changeMigrationStartedEventCount()).isEqualTo(1);
assertThat(eventMonitor.changeMigrationFinishedEventCount()).isEqualTo(1);
ChangeMigrationFinishedEvent event = Iterables.getOnlyElement(eventMonitor.changeMigrationFinishedEvents);
DestinationEffect effect = Iterables.getOnlyElement(event.getDestinationEffects());
assertThat(effect.getSummary()).isEqualTo(expectedSummary);
assertThat(effect.getOriginRefs()).hasSize(1);
assertThat(effect.getOriginRefs().get(0).getRef()).isEqualTo(expectedOriginRef);
DestinationRef destinationRef = effect.getDestinationRef();
assertThat(destinationRef.getId()).isEqualTo(expectedDestRef);
assertThat(destinationRef.getType()).isEqualTo(expectedDestType);
if (expectedDestUrl == null) {
assertThat(destinationRef.getUrl()).isNull();
} else {
assertThat(destinationRef.getUrl()).isEqualTo(expectedDestUrl);
}
assertThat(effect.getErrors()).containsExactlyElementsIn(expectedErrors);
}
use of com.google.copybara.feedback.Feedback in project copybara by google.
the class FeedbackTest method testMultipleSourceRefs.
@Test
public void testMultipleSourceRefs() throws Exception {
Feedback feedback = loggingFeedback();
feedback.run(workdir, ImmutableList.of("12345", "67890"));
console.assertThat().matchesNext(MessageType.INFO, ".*Ref: 12345").matchesNext(MessageType.INFO, ".*Feedback name: default").matchesNext(MessageType.INFO, ".*Action name: test_action").matchesNext(MessageType.INFO, ".*Ref: 67890").matchesNext(MessageType.INFO, ".*Feedback name: default").matchesNext(MessageType.INFO, ".*Action name: test_action").matchesNext(MessageType.INFO, ".*Action 'test_action' returned success.*");
}
use of com.google.copybara.feedback.Feedback in project copybara by google.
the class FeedbackTest method testDescribeActions.
@Test
public void testDescribeActions() throws Exception {
Feedback feedback = feedback("" + "def _action1(ctx):\n" + " return ctx.success()\n" + "\n" + "def _action2(ctx):\n" + " return ctx.success()\n" + "\n" + "def action1(param1):\n" + " return core.action(\n" + " impl = _action1,\n" + " params = {\n" + " 'param1': param1,\n" + " },\n" + " )" + "\n" + "def action2(param1, param2):\n" + " return core.action(\n" + " impl = _action2,\n" + " params = {\n" + " 'param1': param1,\n" + " 'param2': param2,\n" + " },\n" + " )" + "\n", "action1(param1 = 'foo')", "action2(param1 = True, param2 = 'Bar')");
assertThat(feedback.getActionsDescription()).isEqualTo(ImmutableSetMultimap.builder().put("_action1", ImmutableSetMultimap.of("param1", "foo")).put("_action2", ImmutableSetMultimap.of("param1", "true", "param2", "Bar")).build());
}
use of com.google.copybara.feedback.Feedback in project copybara by google.
the class GerritEndpointTest method runFeedback.
private void runFeedback(ImmutableList<String> funBody) throws Exception {
Feedback test = feedback("def test_action(ctx):\n" + funBody.stream().map(s -> " " + s).collect(Collectors.joining("\n")) + "\n return ctx.success()\n");
test.run(workdir, ImmutableList.of("e597746de9c1704e648ddc3ffa0d2096b146d600"));
}
Aggregations