Search in sources :

Example 41 with TestingConsole

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

the class ConsoleTest method captureAllConsole.

@Test
public void captureAllConsole() {
    TestingConsole delegate = new TestingConsole().respondYes();
    CapturingConsole console = CapturingConsole.captureAllConsole(delegate);
    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"), new Message(MessageType.INFO, "This is info"), new Message(MessageType.PROGRESS, "This is progress"));
    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 42 with TestingConsole

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

the class ConsoleTest method testVerbose.

@Test
public void testVerbose() {
    TestingConsole verboseDelegate = new TestingConsole();
    CapturingConsole verboseConsole = CapturingConsole.captureAllConsole(verboseDelegate);
    verboseConsole.verboseFmt("This is %s", "verbose!");
    verboseConsole.verboseFmt("This is also verbose");
    verboseConsole.info("This is info");
    assertThat(verboseConsole.getMessages()).containsExactly(new Message(MessageType.VERBOSE, "This is verbose!"), new Message(MessageType.VERBOSE, "This is also verbose"), new Message(MessageType.INFO, "This is info"));
}
Also used : TestingConsole(com.google.copybara.util.console.testing.TestingConsole) Truth.assertWithMessage(com.google.common.truth.Truth.assertWithMessage) Test(org.junit.Test)

Example 43 with TestingConsole

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

the class MultiplexingConsoleTest method testConsole.

@Test
public void testConsole() {
    TestingConsole delegate1 = new TestingConsole();
    TestingConsole delegate2 = new TestingConsole();
    MultiplexingConsole underTest = new MultiplexingConsole(delegate1, delegate2);
    underTest.startupMessage("v1");
    underTest.info("This is info");
    underTest.warn("This is warning");
    underTest.error("This is error");
    underTest.verbose("This is verbose");
    underTest.progress("This is progress");
    delegate1.assertThat().matchesNext(MessageType.INFO, "Copybara source mover [(]Version: v1[)]").matchesNext(MessageType.INFO, "This is info").matchesNext(MessageType.WARNING, "This is warning").matchesNext(MessageType.ERROR, "This is error").matchesNext(MessageType.VERBOSE, "This is verbose").matchesNext(MessageType.PROGRESS, "This is progress");
    delegate2.assertThat().matchesNext(MessageType.INFO, "Copybara source mover [(]Version: v1[)]").matchesNext(MessageType.INFO, "This is info").matchesNext(MessageType.WARNING, "This is warning").matchesNext(MessageType.ERROR, "This is error").matchesNext(MessageType.VERBOSE, "This is verbose").matchesNext(MessageType.PROGRESS, "This is progress");
}
Also used : TestingConsole(com.google.copybara.util.console.testing.TestingConsole) Test(org.junit.Test)

Example 44 with TestingConsole

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

the class RevisionMigratorTest method setUp.

@Before
public void setUp() throws Exception {
    FileSystem fs = Jimfs.newFileSystem();
    checkoutDir = fs.getPath("/test-checkoutDir");
    origin = new DummyOrigin();
    destinationReader = new MockReader();
    location = Location.fromFileLineColumn("file", 1, 2);
    referenceMigrator = ReferenceMigrator.create("http://internalReviews.com/${reference}", "http://externalreviews.com/view?${reference}", Pattern.compile("[0-9]+"), Pattern.compile("[0-9a-f]+"), ImmutableList.of(), location);
    OptionsBuilder options = new OptionsBuilder();
    console = new TestingConsole();
    options.setConsole(console);
    skylark = new SkylarkTestExecutor(options);
}
Also used : DummyOrigin(com.google.copybara.testing.DummyOrigin) 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 45 with TestingConsole

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

the class GlobTest method setup.

@Before
public void setup() throws IOException, RepoException {
    workdir = Files.createTempDirectory("workdir");
    OptionsBuilder options = new OptionsBuilder().setWorkdirToRealTempDir().setConsole(new TestingConsole());
    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)

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