Search in sources :

Example 31 with TestingConsole

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

the class CopyOrMoveTest method testAbsoluteAfter.

@Test
public void testAbsoluteAfter() {
    for (String t : ImmutableList.of("move", "copy")) {
        options.setConsole(new TestingConsole());
        skylark.evalFails("core." + t + "(after = '/blablabla', before = 'other')\n", "path must be relative.*/blablabla");
    }
}
Also used : TestingConsole(com.google.copybara.util.console.testing.TestingConsole) Test(org.junit.Test)

Example 32 with TestingConsole

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

the class RemoveTest method setup.

@Before
public void setup() throws IOException {
    FileSystem fs = Jimfs.newFileSystem();
    checkoutDir = fs.getPath("/test-checkoutDir");
    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) FileSystem(java.nio.file.FileSystem) OptionsBuilder(com.google.copybara.testing.OptionsBuilder) SkylarkTestExecutor(com.google.copybara.testing.SkylarkTestExecutor) Before(org.junit.Before)

Example 33 with TestingConsole

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

the class GithubArchiveTest method repoExceptionOnDownloadFailure.

@Test
public void repoExceptionOnDownloadFailure() throws Exception {
    httpTransport = new MockHttpTransport() {

        @Override
        public LowLevelHttpRequest buildRequest(String method, String url) {
            MockLowLevelHttpRequest request = new MockLowLevelHttpRequest() {

                public LowLevelHttpResponse execute() throws IOException {
                    throw new IOException("OH NOES!");
                }
            };
            return request;
        }
    };
    RemoteFileOptions options = new RemoteFileOptions();
    options.transport = () -> new GclientHttpStreamFactory(httpTransport, Duration.ofSeconds(20));
    Console console = new TestingConsole();
    OptionsBuilder optionsBuilder = new OptionsBuilder().setConsole(console);
    optionsBuilder.remoteFile = options;
    skylark = new SkylarkTestExecutor(optionsBuilder);
    ValidationException e = assertThrows(ValidationException.class, () -> skylark.eval("sha256", "sha256 = remotefiles.github_archive(" + "project = 'google/copybara'," + "revision='674ac754f91e64a0efb8087e59a176484bd534d1').sha256()"));
    assertThat(e).hasCauseThat().hasCauseThat().hasCauseThat().isInstanceOf(RepoException.class);
}
Also used : MockHttpTransport(com.google.api.client.testing.http.MockHttpTransport) ValidationException(com.google.copybara.exception.ValidationException) LowLevelHttpRequest(com.google.api.client.http.LowLevelHttpRequest) MockLowLevelHttpRequest(com.google.api.client.testing.http.MockLowLevelHttpRequest) IOException(java.io.IOException) OptionsBuilder(com.google.copybara.testing.OptionsBuilder) SkylarkTestExecutor(com.google.copybara.testing.SkylarkTestExecutor) MockLowLevelHttpRequest(com.google.api.client.testing.http.MockLowLevelHttpRequest) TestingConsole(com.google.copybara.util.console.testing.TestingConsole) MockLowLevelHttpResponse(com.google.api.client.testing.http.MockLowLevelHttpResponse) LowLevelHttpResponse(com.google.api.client.http.LowLevelHttpResponse) TestingConsole(com.google.copybara.util.console.testing.TestingConsole) Console(com.google.copybara.util.console.Console) Test(org.junit.Test)

Example 34 with TestingConsole

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

the class SkylarkTestExecutorTest method setup.

@Before
public void setup() {
    TestingConsole console = new TestingConsole();
    OptionsBuilder options = new OptionsBuilder();
    options.setConsole(console);
    skylark = new SkylarkTestExecutor(options).withStaticModules(ImmutableSet.of(DummyModule.class));
}
Also used : TestingConsole(com.google.copybara.util.console.testing.TestingConsole) Before(org.junit.Before)

Example 35 with TestingConsole

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

the class CoreTest method setup.

@Before
public void setup() {
    console = new TestingConsole();
    options = new OptionsBuilder();
    options.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)

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