use of com.google.copybara.util.console.Message in project copybara by google.
the class WorkflowTest method testNullOrigin.
@Test
public void testNullOrigin() throws Exception {
ValidationException e = assertThrows(ValidationException.class, () -> loadConfig("" + "core.workflow(\n" + " name = 'foo',\n" + " authoring = " + authoring + "\n," + " destination = testing.destination(),\n" + ")\n"));
for (Message message : console().getMessages()) {
System.err.println(message);
}
console().assertThat().onceInLog(MessageType.ERROR, ".*missing 1 required named argument: origin.*");
}
use of com.google.copybara.util.console.Message in project copybara by google.
the class GerritDestinationTest method assertPushRef.
private void assertPushRef(String ref) {
ImmutableList<Message> messages = console.getMessages();
for (Message message : messages) {
if (message.getText().matches(".*Pushing to .*" + ref + ".*")) {
return;
}
}
assertWithMessage(String.format("'%s' not found in:\n %s", ref, Joiner.on("\n ").join(messages))).fail();
}
use of com.google.copybara.util.console.Message in project copybara by google.
the class GerritDestinationTest method testReviewerFieldWithLabel.
@Test
public void testReviewerFieldWithLabel() throws Exception {
pushToRefsFor = "master%label=Foo";
writeFile(workdir, "file", "some content");
fetch = "master";
options.setForce(true);
url = "https://localhost:33333/foo/bar";
mockNoChangesFound();
DummyRevision originRef = new DummyRevision("origin_ref");
GerritDestination destination = destination("submit = False", "reviewers = [\"${SOME_REVIEWER}\"]");
Glob glob = Glob.createGlob(ImmutableList.of("**"), excludedDestinationPaths);
WriterContext writerContext = new WriterContext("GerritDestination", "TEST", false, new DummyRevision("test"), Glob.ALL_FILES.roots());
List<DestinationEffect> result = destination.newWriter(writerContext).write(TransformResults.of(workdir, originRef).withSummary("Test message").withIdentity(originRef.asString()).withLabelFinder(e -> e.equals("SOME_REVIEWER") ? ImmutableList.of("foo@example.com") : ImmutableList.of()), glob, console);
assertThat(result).hasSize(1);
assertThat(result.get(0).getErrors()).isEmpty();
assertPushRef("refs/for/master%label=Foo,hashtag=copybara_id_origin_ref_commiter@email," + "r=foo@example.com");
}
use of com.google.copybara.util.console.Message in project copybara by google.
the class GerritDestinationTest method testReviewerFieldWithTopic.
@Test
public void testReviewerFieldWithTopic() throws Exception {
pushToRefsFor = "master";
writeFile(workdir, "file", "some content");
fetch = "master";
options.gerrit.gerritTopic = "testTopic";
options.setForce(true);
url = "https://localhost:33333/foo/bar";
mockNoChangesFound();
DummyRevision originRef = new DummyRevision("origin_ref");
GerritDestination destination = destination("submit = False", "reviewers = [\"${SOME_REVIEWER}\"]");
Glob glob = Glob.createGlob(ImmutableList.of("**"), excludedDestinationPaths);
WriterContext writerContext = new WriterContext("GerritDestination", "TEST", false, new DummyRevision("test"), Glob.ALL_FILES.roots());
List<DestinationEffect> result = destination.newWriter(writerContext).write(TransformResults.of(workdir, originRef).withSummary("Test message").withIdentity(originRef.asString()).withLabelFinder(e -> e.equals("SOME_REVIEWER") ? ImmutableList.of("foo@example.com") : ImmutableList.of()), glob, console);
assertThat(result).hasSize(1);
assertThat(result.get(0).getErrors()).isEmpty();
assertPushRef("refs/for/master%topic=testTopic,hashtag=copybara_id_origin_ref_commiter@email," + "r=foo@example.com");
}
use of com.google.copybara.util.console.Message in project copybara by google.
the class OnboardCmdTest method testOnboardCmdTextAdventure.
@Test
public void testOnboardCmdTextAdventure() throws Exception {
TestingConsole console = new TestingConsole();
console.respondWithString("https://github.com/google/origin").respondWithString("https://github.com/google/destination").respondWithString("Copybara <copy@bara.com>");
optionsBuilder.setConsole(console);
OnboardCmd onboardCmd = new OnboardCmd();
ExitCode exit = onboardCmd.run(new CommandEnv(temp, skylark.createModuleSet().getOptions(), ImmutableList.of("copy.bara.sky")));
assertThat(exit).isEqualTo(ExitCode.SUCCESS);
ConfigBuilder expectedConfig = new ConfigBuilder(new GitToGitTemplate());
expectedConfig.setNamedStringParameter("origin_url", "https://github.com/google/origin");
expectedConfig.setNamedStringParameter("destination_url", "https://github.com/google/destination");
expectedConfig.setNamedStringParameter("email", "Copybara <copy@bara.com>");
assertThat(Joiner.on('\n').join(console.getMessages().stream().map(Message::getText).collect(Collectors.toList()))).contains(expectedConfig.build());
}
Aggregations