use of com.google.copybara.feedback.Feedback in project copybara by google.
the class GerritEndpointTest method testCheckerIsHonored.
@Test
public void testCheckerIsHonored() throws Exception {
String config = "" + "def test_action(ctx):\n" + " ctx.destination.get_change('12_badword_34', include_results = ['LABELS'])\n" + " return ctx.success()\n" + "\n" + "core.feedback(\n" + " name = 'default',\n" + " origin = testing.dummy_trigger(),\n" + " destination = git.gerrit_api(" + " url = 'https://test.googlesource.com/example',\n" + " checker = testing.dummy_checker(),\n" + " ),\n" + " actions = [test_action,],\n" + ")\n" + "\n";
Feedback feedback = (Feedback) skylark.loadConfig(config).getMigration("default");
ValidationException expected = assertThrows(ValidationException.class, () -> feedback.run(workdir, ImmutableList.of("12345")));
assertThat(expected).hasMessageThat().contains("Bad word 'badword' found: field 'path'.");
}
use of com.google.copybara.feedback.Feedback in project copybara by google.
the class GitHubEndpointTest method feedback.
private Feedback feedback(String actionFunction) throws IOException, ValidationException {
String config = actionFunction + "\n" + "core.feedback(\n" + " name = 'default',\n" + " origin = testing.dummy_trigger(),\n" + " destination = git.github_api(\n" + " url = 'https://github.com/google/example',\n" + " ),\n" + " actions = [test_action,],\n" + ")\n" + "\n";
System.err.println(config);
return (Feedback) skylark.loadConfig(config).getMigration("default");
}
use of com.google.copybara.feedback.Feedback in project copybara by google.
the class GitHubEndpointTest method testCheckerIsHonored.
@Test
public void testCheckerIsHonored() throws Exception {
String config = "" + "def test_action(ctx):\n" + " ctx.destination.update_reference(\n" + " 'e597746de9c1704e648ddc3ffa0d2096b146d600', 'foo_badword_bar', True)\n" + " return ctx.success()\n" + "\n" + "core.feedback(\n" + " name = 'default',\n" + " origin = testing.dummy_trigger(),\n" + " destination = git.github_api(" + " url = 'https://github.com/google/example',\n" + " checker = testing.dummy_checker(),\n" + " ),\n" + " actions = [test_action,],\n" + ")\n" + "\n";
Feedback feedback = (Feedback) skylark.loadConfig(config).getMigration("default");
assertThat(feedback.getDestinationDescription().get("url")).containsExactly("https://github.com/google/example");
ValidationException expected = assertThrows(ValidationException.class, () -> feedback.run(workdir, ImmutableList.of("12345")));
assertThat(expected).hasMessageThat().contains("Bad word 'badword' found: field 'path'.");
}
use of com.google.copybara.feedback.Feedback in project copybara by google.
the class GitHubEndpointTest 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