Search in sources :

Example 96 with TestingConsole

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

the class FileConsoleTest method testFlushingFrequencyDeactivated.

/**
 * We only flush when the file is closed
 */
@Test
public void testFlushingFrequencyDeactivated() throws Exception {
    TestingConsole delegate = new TestingConsole();
    try (FileConsole fileConsole = new FileConsole(delegate, file, Duration.ZERO)) {
        fileConsole.startupMessage("v1");
        fileConsole.info("This is info");
        fileConsole.warn("This is warning");
        assertThat(Files.readAllLines(file)).isEmpty();
        Thread.sleep(3000);
        fileConsole.error("This is error");
        fileConsole.verbose("This is verbose");
        List<String> lines = Files.readAllLines(file);
        assertThat(lines).hasSize(0);
        fileConsole.progress("This is progress");
    }
    List<String> lines = Files.readAllLines(file);
    assertThat(lines).hasSize(6);
    assertThat(lines.get(0)).contains("INFO: Copybara source mover (Version: v1)");
    assertThat(lines.get(1)).contains("INFO: This is info");
    assertThat(lines.get(2)).contains("WARNING: This is warning");
    assertThat(lines.get(3)).contains("ERROR: This is error");
    assertThat(lines.get(4)).contains("VERBOSE: This is verbose");
    assertThat(lines.get(5)).contains("PROGRESS: This is progress");
}
Also used : 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