Search in sources :

Example 1 with CommandEnv

use of com.google.copybara.CommandEnv 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());
}
Also used : TestingConsole(com.google.copybara.util.console.testing.TestingConsole) Message(com.google.copybara.util.console.Message) ExitCode(com.google.copybara.util.ExitCode) CommandEnv(com.google.copybara.CommandEnv) Test(org.junit.Test)

Example 2 with CommandEnv

use of com.google.copybara.CommandEnv 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");
}
Also used : TestingConsole(com.google.copybara.util.console.testing.TestingConsole) Message(com.google.copybara.util.console.Message) CommandEnv(com.google.copybara.CommandEnv) Test(org.junit.Test)

Example 3 with CommandEnv

use of com.google.copybara.CommandEnv 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());
}
Also used : TestingConsole(com.google.copybara.util.console.testing.TestingConsole) Message(com.google.copybara.util.console.Message) CommandEnv(com.google.copybara.CommandEnv) Test(org.junit.Test)

Aggregations

CommandEnv (com.google.copybara.CommandEnv)3 Message (com.google.copybara.util.console.Message)3 TestingConsole (com.google.copybara.util.console.testing.TestingConsole)3 Test (org.junit.Test)3 ExitCode (com.google.copybara.util.ExitCode)1