use of com.google.copybara.feedback.Feedback in project copybara by google.
the class FeedbackTest method testNoopResultThrowsEmptyChangeException.
@Test
public void testNoopResultThrowsEmptyChangeException() throws Exception {
Feedback feedback = feedback("" + "def test_action_1(ctx):\n" + " return ctx.noop('No effect 1')\n" + "\n" + "def test_action_2(ctx):\n" + " return ctx.noop('No effect 2')\n" + "\n", "test_action_1", "test_action_2");
EmptyChangeException expected = assertThrows(EmptyChangeException.class, () -> feedback.run(workdir, ImmutableList.of()));
assertThat(expected).hasMessageThat().contains("Feedback migration 'default' was noop. " + "Detailed messages: [No effect 1, No effect 2]");
console.assertThat().equalsNext(MessageType.INFO, "Action 'test_action_1' returned noop: No effect 1").equalsNext(MessageType.INFO, "Action 'test_action_2' returned noop: No effect 2");
}
use of com.google.copybara.feedback.Feedback in project copybara by google.
the class FeedbackTest method testRefReturnsNone.
@Test
public void testRefReturnsNone() throws Exception {
Feedback feedback = feedback("" + "def test_action(ctx):\n" + " ref = None\n" + " if len(ctx.refs) > 0:\n" + " ref = ctx.refs[0]\n" + " ctx.console.info('Ref: '+ str(ref))\n" + " return ctx.success()\n" + "\n", "test_action");
feedback.run(workdir, ImmutableList.of());
console.assertThat().matchesNext(MessageType.INFO, ".*Ref: None").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 testSuccessResult.
@Test
public void testSuccessResult() throws Exception {
Feedback feedback = feedback("" + "def test_action(ctx):\n" + " return ctx.success()\n", "test_action");
feedback.run(workdir, ImmutableList.of());
console.assertThat().equalsNext(MessageType.INFO, "Action 'test_action' returned success");
}
use of com.google.copybara.feedback.Feedback in project copybara by google.
the class FeedbackTest method testNoopSuccessReturnsSuccess.
@Test
public void testNoopSuccessReturnsSuccess() throws Exception {
Feedback feedback = feedback("" + "def test_action_1(ctx):\n" + " return ctx.noop('No effect')\n" + "\n" + "def test_action_2(ctx):\n" + " return ctx.success()\n" + "\n", "test_action_1", "test_action_2");
feedback.run(workdir, ImmutableList.of());
console.assertThat().equalsNext(MessageType.INFO, "Action 'test_action_1' returned noop: No effect").equalsNext(MessageType.INFO, "Action 'test_action_2' returned success").containsNoMoreMessages();
}
use of com.google.copybara.feedback.Feedback in project copybara by google.
the class FeedbackTest method testNoActionsThrowsEmptyChangeException.
@Test
public void testNoActionsThrowsEmptyChangeException() throws Exception {
Feedback feedback = feedback("");
EmptyChangeException expected = assertThrows(EmptyChangeException.class, () -> feedback.run(workdir, ImmutableList.of()));
assertThat(expected).hasMessageThat().contains("Feedback migration 'default' was noop. Detailed messages: actions field is empty");
}
Aggregations