use of com.google.copybara.util.console.Message in project copybara by google.
the class GerritDestinationTest method testReviewersFieldWithTopic.
@Test
public void testReviewersFieldWithTopic() 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", "bar@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,r=bar@example.com");
}
use of com.google.copybara.util.console.Message in project copybara by google.
the class CommandLineGuideTest method testGitToGitTemplatePredicateNotSatisfied.
@Test
public void testGitToGitTemplatePredicateNotSatisfied() {
String urlPrefix = "https://github.com/google/";
TestingConsole console = new TestingConsole();
console.respondWithString(urlPrefix.concat("origin")).respondWithString(urlPrefix.concat("destination")).respondWithString("not a valid email");
optionsBuilder.setConsole(console);
CommandLineGuide.runForCommandLine(new CommandEnv(temp, skylark.createModuleSet().getOptions(), ImmutableList.of("copy.bara.sky")));
assertThat(Joiner.on('\n').join(console.getMessages().stream().map(Message::getText).collect(Collectors.toList()))).contains("Invalid response");
}
use of com.google.copybara.util.console.Message in project copybara by google.
the class CommandLineGuideTest method testGitToGitTemplate.
@Test
public void testGitToGitTemplate() {
TestingConsole console = new TestingConsole();
String urlPrefix = "https://github.com/google/";
console.respondWithString(urlPrefix.concat("origin")).respondWithString(urlPrefix.concat("destination")).respondWithString("Copybara <copy@bara.com>");
optionsBuilder.setConsole(console);
CommandLineGuide.runForCommandLine(new CommandEnv(temp, skylark.createModuleSet().getOptions(), ImmutableList.of("copy.bara.sky")));
ConfigBuilder expectedConfig = new ConfigBuilder(new GitToGitTemplate());
expectedConfig.setNamedStringParameter("origin_url", urlPrefix.concat("origin"));
expectedConfig.setNamedStringParameter("destination_url", urlPrefix.concat("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