Search in sources :

Example 91 with TestingConsole

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

the class FilterReplaceTest 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 92 with TestingConsole

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

the class MetadataModuleTest method setup.

@Before
public void setup() throws Exception {
    options = new OptionsBuilder();
    authoring = "authoring.overwrite('" + DEFAULT_AUTHOR + "')";
    workdir = Files.createTempDirectory("workdir");
    Files.createDirectories(workdir);
    origin = new DummyOrigin().setAuthor(ORIGINAL_AUTHOR);
    destination = new RecordsProcessCallDestination();
    options.setConsole(new TestingConsole());
    options.testingOptions.origin = origin;
    options.testingOptions.destination = destination;
    skylark = new SkylarkTestExecutor(options);
    origin.addSimpleChange(0, "first commit\n\nExtended text").setAuthor(FOO_BAR).addSimpleChange(1, "second commit\n\nExtended text").setAuthor(FOO_BAZ).addSimpleChange(2, "third commit\n\nExtended text");
    options.setLastRevision("0");
    // We don't care about already migrated code
    options.setForce(true);
    testingConsole = new TestingConsole();
    options.setConsole(testingConsole);
}
Also used : RecordsProcessCallDestination(com.google.copybara.testing.RecordsProcessCallDestination) DummyOrigin(com.google.copybara.testing.DummyOrigin) 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 93 with TestingConsole

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

the class QuiltTransformationTest method setUp.

@Before
public void setUp() throws IOException {
    checkoutDir = Files.createTempDirectory("workdir");
    Files.createDirectories(checkoutDir);
    console = new TestingConsole();
    // QuiltTransformation needs to write and read from to real temp directory.
    options = new OptionsBuilder().setWorkdirToRealTempDir();
    // GeneralOptions.getDirFactory() requires $HOME to be set. We set --output-root instead.
    options.setOutputRootToTmpDir();
    patchingOptions = options.build().get(PatchingOptions.class);
    patchingOptions.quiltBin = setUpQuiltBin(patchingOptions.getGeneralOptions());
    skylark = new SkylarkTestExecutor(options);
    ImmutableMap<String, byte[]> configFiles = ImmutableMap.of("patches/diff.patch", OLDDIFF.getBytes(UTF_8), "patches/series", SERIES.getBytes(UTF_8));
    patchFile = new MapConfigFile(configFiles, "patches/diff.patch");
    seriesFile = new MapConfigFile(configFiles, "patches/series");
}
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 94 with TestingConsole

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

the class ConsoleTest method fmtMethodsWork.

@Test
public void fmtMethodsWork() throws Exception {
    TestingConsole delegate = new TestingConsole().respondYes();
    CapturingConsole console = CapturingConsole.captureAllConsole(delegate);
    console.errorFmt("This is %s", "error!");
    console.warnFmt("This is %s", "warning");
    console.infoFmt("This is %s", "info");
    console.progressFmt("This is %s", "progress");
    assertThat(console.promptConfirmationFmt("Do you want to %s?", "continue")).isTrue();
    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"));
}
Also used : TestingConsole(com.google.copybara.util.console.testing.TestingConsole) Truth.assertWithMessage(com.google.common.truth.Truth.assertWithMessage) Test(org.junit.Test)

Example 95 with TestingConsole

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

the class DelegateConsoleTest method testConsole.

@Test
public void testConsole() {
    TestingConsole delegate = new TestingConsole();
    List<Message> messages = new ArrayList<>();
    DelegateConsole delegating = new DelegateConsole(delegate) {

        @Override
        protected void handleMessage(MessageType type, String message) {
            messages.add(new Message(type, message));
        }
    };
    delegating.startupMessage("v1");
    delegating.info("This is info");
    delegating.warn("This is warning");
    delegating.error("This is error");
    delegating.verbose("This is verbose");
    delegating.progress("This is progress");
    assertThat(messages).containsExactly(new Message(MessageType.INFO, "Copybara source mover (Version: v1)"), new Message(MessageType.INFO, "This is info"), new Message(MessageType.WARNING, "This is warning"), new Message(MessageType.ERROR, "This is error"), new Message(MessageType.VERBOSE, "This is verbose"), new Message(MessageType.PROGRESS, "This is progress"));
    delegate.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) ArrayList(java.util.ArrayList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) MessageType(com.google.copybara.util.console.Message.MessageType) 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