use of com.google.copybara.feedback.Feedback in project copybara by google.
the class FeedbackTest method testErrorResultEmptyMsg.
@Test
public void testErrorResultEmptyMsg() throws Exception {
Feedback feedback = feedback("" + "def test_action(ctx):\n" + " result = ctx.error()\n" + "\n", "test_action");
ValidationException expected = assertThrows(ValidationException.class, () -> feedback.run(workdir, ImmutableList.of()));
assertThat(expected).hasMessageThat().contains("missing 1 required positional argument: msg");
}
use of com.google.copybara.feedback.Feedback in project copybara by google.
the class FeedbackTest method testParsing.
@Test
public void testParsing() throws Exception {
Feedback feedback = loggingFeedback();
assertThat(feedback.getName()).isEqualTo("default");
assertThat(feedback.getModeString()).isEqualTo("feedback");
assertThat(feedback.getMainConfigFile()).isNotNull();
assertThat(feedback.getOriginDescription()).isEqualTo(dummyTrigger.describe());
assertThat(feedback.getDestinationDescription()).isEqualTo(dummyTrigger.describe());
assertThat(feedback.getActionsDescription()).containsEntry("test_action", ImmutableSetMultimap.of());
}
use of com.google.copybara.feedback.Feedback in project copybara by google.
the class FeedbackTest method testErrorResultAbortsExecution.
@Test
public void testErrorResultAbortsExecution() throws Exception {
Feedback feedback = feedback("" + "def test_action_1(ctx):\n" + " return ctx.error('This is an error')\n" + "\n" + "def test_action_2(ctx):\n" + " return ctx.success()\n", "test_action_1", "test_action_2");
ValidationException expected = assertThrows(ValidationException.class, () -> feedback.run(workdir, ImmutableList.of()));
assertThat(expected).hasMessageThat().contains("Feedback migration 'default' action 'test_action_1' returned error: " + "This is an error. Aborting execution.");
console.assertThat().equalsNext(MessageType.ERROR, "Action 'test_action_1' returned error: This is an error").containsNoMoreMessages();
}
use of com.google.copybara.feedback.Feedback in project copybara by google.
the class FeedbackTest method verifyCliLabels.
@Test
public void verifyCliLabels() throws Exception {
options.general.setCliLabelsForTest(ImmutableMap.of("foo", "value"));
Feedback feedback = feedback("" + "def test_action(ctx):\n" + " foo = ctx.cli_labels['foo']\n" + " ctx.console.info('foo is: ' + foo)\n" + " return ctx.success()\n" + "\n", "test_action");
feedback.run(workdir, ImmutableList.of());
console.assertThat().matchesNext(MessageType.INFO, ".*foo is: value").matchesNext(MessageType.INFO, ".*Action 'test_action' returned success.*").containsNoMoreMessages();
}
use of com.google.copybara.feedback.Feedback in project copybara by google.
the class FeedbackTest method testEvalExceptionIncludesLocation.
@Test
public void testEvalExceptionIncludesLocation() throws Exception {
Feedback feedback = feedback("" + "def test_action(ctx):\n" + " result = ctx.foo()\n" + "\n", "test_action");
ValidationException ex = assertThrows(ValidationException.class, () -> feedback.run(workdir, ImmutableList.of()));
assertThat(ex).hasMessageThat().contains("Error while executing the skylark transformation test_action");
assertThat(ex).hasMessageThat().contains("File \"copy.bara.sky\", line 2, column 17, in test_action");
assertThat(ex).hasMessageThat().contains("'feedback.context' value has no field or method 'foo'");
}
Aggregations