Search in sources :

Example 36 with TestingConsole

use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.

the class ReplaceTest method setup.

@Before
public void setup() throws IOException {
    fs = Jimfs.newFileSystem();
    checkoutDir = fs.getPath("/");
    Files.createDirectories(checkoutDir);
    console = new TestingConsole();
    options = new OptionsBuilder().setConsole(console);
    skylark = new SkylarkTestExecutor(options);
}
Also used : TestingConsole(com.google.copybara.util.console.testing.TestingConsole) OptionsBuilder(com.google.copybara.testing.OptionsBuilder) SkylarkTestExecutor(com.google.copybara.testing.SkylarkTestExecutor) Before(org.junit.Before)

Example 37 with TestingConsole

use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.

the class TodoReplaceTest method setup.

@Before
public void setup() throws IOException {
    FileSystem fs = Jimfs.newFileSystem();
    checkoutDir = fs.getPath("/");
    Files.createDirectories(checkoutDir);
    console = new TestingConsole();
    OptionsBuilder options = new OptionsBuilder().setConsole(console);
    skylark = new SkylarkTestExecutor(options);
}
Also used : TestingConsole(com.google.copybara.util.console.testing.TestingConsole) FileSystem(java.nio.file.FileSystem) OptionsBuilder(com.google.copybara.testing.OptionsBuilder) SkylarkTestExecutor(com.google.copybara.testing.SkylarkTestExecutor) Before(org.junit.Before)

Example 38 with TestingConsole

use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.

the class PatchTransformationTest method setup.

@Before
public void setup() throws IOException {
    checkoutDir = Files.createTempDirectory("workdir");
    Files.createDirectories(checkoutDir);
    console = new TestingConsole();
    options = new OptionsBuilder().setConsole(console);
    patchingOptions = options.build().get(PatchingOptions.class);
    skylark = new SkylarkTestExecutor(options);
    ImmutableMap<String, byte[]> configFiles = ImmutableMap.of("diff.patch", (DIFF).getBytes(UTF_8), "series", ("diff.patch\n").getBytes(UTF_8));
    patchFile = new MapConfigFile(configFiles, "diff.patch");
    seriesFile = new MapConfigFile(configFiles, "series");
    options.setEnvironment(GitTestUtil.getGitEnv().getEnvironment());
    // In preparation to switch to the new default. PatchingOptionsTest has more coverage on this.
    options.patch.useGitApply = false;
    options.patch.skipVersionCheck = false;
}
Also used : TestingConsole(com.google.copybara.util.console.testing.TestingConsole) MapConfigFile(com.google.copybara.config.MapConfigFile) OptionsBuilder(com.google.copybara.testing.OptionsBuilder) SkylarkTestExecutor(com.google.copybara.testing.SkylarkTestExecutor) Before(org.junit.Before)

Example 39 with TestingConsole

use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.

the class ConsoleTest method captureOnlyConsole.

@Test
public void captureOnlyConsole() throws Exception {
    TestingConsole delegate = new TestingConsole().respondYes();
    CapturingConsole console = CapturingConsole.captureOnlyConsole(delegate, MessageType.ERROR, MessageType.WARNING);
    console.error("This is error!");
    console.warn("This is warning");
    console.info("This is info");
    console.progress("This is progress");
    console.promptConfirmation("Do you want to continue?");
    assertThat(console.getMessages()).containsExactly(new Message(MessageType.ERROR, "This is error!"), new Message(MessageType.WARNING, "This is warning"));
    delegate.assertThat().matchesNext(MessageType.ERROR, "This is error!").matchesNext(MessageType.WARNING, "This is warning").matchesNext(MessageType.INFO, "This is info").matchesNext(MessageType.PROGRESS, "This is progress").matchesNext(MessageType.WARNING, "Do you want to continue[?]").containsNoMoreMessages();
}
Also used : TestingConsole(com.google.copybara.util.console.testing.TestingConsole) Truth.assertWithMessage(com.google.common.truth.Truth.assertWithMessage) Test(org.junit.Test)

Example 40 with TestingConsole

use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.

the class ConsoleTest method progressPrefix.

@Test
public void progressPrefix() {
    TestingConsole delegate = new TestingConsole();
    Console console = new PrefixConsole("FOO ", delegate);
    console.progress("bar");
    console.info("bar");
    console.warn("bar");
    console.error("bar");
    delegate.assertThat().matchesNext(MessageType.PROGRESS, "FOO bar").matchesNext(MessageType.INFO, "FOO bar").matchesNext(MessageType.WARNING, "FOO bar").matchesNext(MessageType.ERROR, "FOO bar").containsNoMoreMessages();
}
Also used : TestingConsole(com.google.copybara.util.console.testing.TestingConsole) TestingConsole(com.google.copybara.util.console.testing.TestingConsole) Test(org.junit.Test)

Aggregations

TestingConsole (com.google.copybara.util.console.testing.TestingConsole)96 Before (org.junit.Before)57 OptionsBuilder (com.google.copybara.testing.OptionsBuilder)55 SkylarkTestExecutor (com.google.copybara.testing.SkylarkTestExecutor)54 Test (org.junit.Test)34 Path (java.nio.file.Path)15 GitTestUtil (com.google.copybara.testing.git.GitTestUtil)8 FileSystem (java.nio.file.FileSystem)8 IOException (java.io.IOException)7 LowLevelHttpRequest (com.google.api.client.http.LowLevelHttpRequest)6 DummyChecker (com.google.copybara.testing.DummyChecker)6 DummyOrigin (com.google.copybara.testing.DummyOrigin)6 Console (com.google.copybara.util.console.Console)6 MockHttpTransport (com.google.api.client.testing.http.MockHttpTransport)5 MockLowLevelHttpRequest (com.google.api.client.testing.http.MockLowLevelHttpRequest)5 MockLowLevelHttpResponse (com.google.api.client.testing.http.MockLowLevelHttpResponse)5 Truth.assertWithMessage (com.google.common.truth.Truth.assertWithMessage)5 GitRepository (com.google.copybara.git.GitRepository)5 LowLevelHttpResponse (com.google.api.client.http.LowLevelHttpResponse)4 RepoException (com.google.copybara.exception.RepoException)4