Search in sources :

Example 51 with TestingConsole

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

the class CopybaraTest method setUp.

@Before
public void setUp() throws Exception {
    optionsBuilder = new OptionsBuilder();
    console = new TestingConsole();
    eventMonitor = new TestingEventMonitor();
    optionsBuilder.setConsole(console);
    optionsBuilder.general.withEventMonitor(eventMonitor);
    migration = mock(Migration.class);
    config = new Config(ImmutableMap.of("workflow", migration), "foo/copy.bara.sky");
}
Also used : TestingConsole(com.google.copybara.util.console.testing.TestingConsole) Migration(com.google.copybara.config.Migration) Config(com.google.copybara.config.Config) OptionsBuilder(com.google.copybara.testing.OptionsBuilder) TestingEventMonitor(com.google.copybara.testing.TestingEventMonitor) Before(org.junit.Before)

Example 52 with TestingConsole

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

the class CoreReverseTest method setup.

@Before
public void setup() {
    OptionsBuilder options = new OptionsBuilder();
    skylark = new SkylarkTestExecutor(options).withStaticModules(ImmutableSet.of(Mock.class));
    console = new TestingConsole();
    options.setConsole(console);
}
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 53 with TestingConsole

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

the class MigrateCmdTest method setUp.

@Before
public void setUp() throws Exception {
    console = new TestingConsole();
    temp = Files.createTempDirectory("temp");
    optionsBuilder = new OptionsBuilder();
    optionsBuilder.setConsole(console).setOutputRootToTmpDir();
    optionsBuilder.setForce(true);
    Path userHomeForTest = Files.createTempDirectory("home");
    optionsBuilder.setEnvironment(GitTestUtil.getGitEnv().getEnvironment());
    optionsBuilder.setHomeDir(userHomeForTest.toString());
    eventMonitor = new TestingEventMonitor();
    optionsBuilder.general.enableEventMonitor("just testing", eventMonitor);
    outPut = optionsBuilder.general.getOutputRoot();
    optionsBuilder.general.starlarkMode = StarlarkMode.STRICT.name();
    remote = Files.createTempDirectory("remote");
    repo = GitRepository.newRepo(/*verbose*/
    true, remote, new GitEnvironment(optionsBuilder.general.getEnvironment())).init();
    primaryBranch = repo.getPrimaryBranch();
    Files.createDirectories(remote.resolve("include"));
    Files.write(remote.resolve("include/fileA.txt"), new byte[0]);
    git(remote, "add", "include/fileA.txt");
    git(remote, "commit", "-m", "not include");
    optionsBuilder.setLastRevision(repo.parseRef("HEAD"));
    git(remote, "checkout", primaryBranch);
    Files.write(remote.resolve("include/mainline-file.txt"), new byte[0]);
    git(remote, "add", "include/mainline-file.txt");
    git(remote, "commit", "-m", "message_a!");
    optionsBuilder.general.dryRunMode = true;
    url = "file://" + remote.toFile().getAbsolutePath();
    writeFile(remote, "test.txt", "some content");
    writeFile(remote, "testA.txt", "some content");
    repo.add().files("test.txt", "testA.txt").run();
    git(remote, "commit", "-m", "first file", "--date", COMMIT_TIME);
    optionsBuilder.setForce(true);
    RecordsProcessCallDestination destination = new RecordsProcessCallDestination();
    optionsBuilder.testingOptions.destination = destination;
    skylark = new SkylarkTestExecutor(optionsBuilder);
}
Also used : Path(java.nio.file.Path) RecordsProcessCallDestination(com.google.copybara.testing.RecordsProcessCallDestination) TestingConsole(com.google.copybara.util.console.testing.TestingConsole) GitEnvironment(com.google.copybara.git.GitEnvironment) OptionsBuilder(com.google.copybara.testing.OptionsBuilder) SkylarkTestExecutor(com.google.copybara.testing.SkylarkTestExecutor) TestingEventMonitor(com.google.copybara.testing.TestingEventMonitor) Before(org.junit.Before)

Example 54 with TestingConsole

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

the class TransformWorkTest method setup.

@Before
public void setup() throws IOException {
    origin = new DummyOrigin().setAuthor(ORIGINAL_AUTHOR);
    destination = new RecordsProcessCallDestination();
    OptionsBuilder options = new OptionsBuilder();
    console = new TestingConsole();
    options.setConsole(console);
    options.testingOptions.origin = origin;
    options.testingOptions.destination = destination;
    // We don't care about force for this test
    options.setForce(true);
    skylark = new SkylarkTestExecutor(options);
    workdir = Files.createTempDirectory("workdir");
}
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 55 with TestingConsole

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

the class CoreTransformTest method testIgnoreNoopWithVerboseFalse.

@Test
public void testIgnoreNoopWithVerboseFalse() throws Exception {
    ExplicitReversal t = skylark.eval("x", "x=" + "core.transform([\n" + "    core.replace(\n" + "        before = 'not found',\n" + "        after = 'not important',\n" + "    ),\n" + "]," + "ignore_noop=True)");
    console = new TestingConsole(false);
    options.setConsole(console);
    Files.write(checkoutDir.resolve("file.txt"), "foo".getBytes(UTF_8));
    t.transform(TransformWorks.of(checkoutDir, "msg", console));
    console.assertThat().matchesNext(MessageType.PROGRESS, ".*Replace not found.*").containsNoMoreMessages();
}
Also used : TestingConsole(com.google.copybara.util.console.testing.TestingConsole) ExplicitReversal(com.google.copybara.transform.ExplicitReversal) 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