Search in sources :

Example 86 with TestingConsole

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

the class SkylarkTransformationTest 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);
    transformWork = TransformWorks.of(checkoutDir, "testmsg", console);
}
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 87 with TestingConsole

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

the class VerifyMatchTest method setup.

@Before
public void setup() throws IOException {
    FileSystem 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) FileSystem(java.nio.file.FileSystem) OptionsBuilder(com.google.copybara.testing.OptionsBuilder) SkylarkTestExecutor(com.google.copybara.testing.SkylarkTestExecutor) Before(org.junit.Before)

Example 88 with TestingConsole

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

the class ConsoleProfilerListenerTest method testConsoleProfilerListener.

@Test
public void testConsoleProfilerListener() {
    TestingConsole console = new TestingConsole();
    profiler.init(ImmutableList.of(new ConsoleProfilerListener(console)));
    try (ProfilerTask ignore = profiler.start("iterative")) {
        ticker.advance(10, TimeUnit.MILLISECONDS);
        try (ProfilerTask ignore2 = profiler.start("origin.checkout")) {
            ticker.advance(5, TimeUnit.MILLISECONDS);
        }
        try (ProfilerTask ignore3 = profiler.start("transforms")) {
            ticker.advance(20, TimeUnit.MILLISECONDS);
        }
        try (ProfilerTask ignore4 = profiler.start("destination.write")) {
            ticker.advance(3, TimeUnit.MILLISECONDS);
        }
    }
    profiler.stop();
    console.assertThat().matchesNextSkipAhead(VERBOSE, "PROFILE:.*6 //copybara/iterative/origin.checkout").matchesNextSkipAhead(VERBOSE, "PROFILE:.*21 //copybara/iterative/transforms").matchesNextSkipAhead(VERBOSE, "PROFILE:.*4 //copybara/iterative/destination.write").matchesNextSkipAhead(VERBOSE, "PROFILE:.*45 //copybara/iterative").matchesNextSkipAhead(VERBOSE, "PROFILE:.*47 //copybara");
}
Also used : TestingConsole(com.google.copybara.util.console.testing.TestingConsole) ProfilerTask(com.google.copybara.profiler.Profiler.ProfilerTask) Test(org.junit.Test)

Example 89 with TestingConsole

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

the class GithubArchiveTest method setup.

@Before
public void setup() throws IOException {
    httpTransport = new MockHttpTransport() {

        @Override
        public LowLevelHttpRequest buildRequest(String method, String url) {
            String requestString = method + " " + url;
            MockLowLevelHttpRequest request = new MockLowLevelHttpRequest();
            MockLowLevelHttpResponse response = new MockLowLevelHttpResponse();
            request.setResponse(response);
            response.setStatusCode(200);
            response.setContent(responseContent);
            if (!url.equals(expectedRequest)) {
                response.setStatusCode(404);
                response.setContent(String.format("UNEXPECTED REQUEST (Returning 404) REQUEST: %s, expected: %s", requestString, expectedRequest));
            }
            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);
}
Also used : TestingConsole(com.google.copybara.util.console.testing.TestingConsole) MockHttpTransport(com.google.api.client.testing.http.MockHttpTransport) MockLowLevelHttpResponse(com.google.api.client.testing.http.MockLowLevelHttpResponse) LowLevelHttpRequest(com.google.api.client.http.LowLevelHttpRequest) MockLowLevelHttpRequest(com.google.api.client.testing.http.MockLowLevelHttpRequest) TestingConsole(com.google.copybara.util.console.testing.TestingConsole) Console(com.google.copybara.util.console.Console) OptionsBuilder(com.google.copybara.testing.OptionsBuilder) SkylarkTestExecutor(com.google.copybara.testing.SkylarkTestExecutor) MockLowLevelHttpRequest(com.google.api.client.testing.http.MockLowLevelHttpRequest) Before(org.junit.Before)

Example 90 with TestingConsole

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

the class RemoteFileModuleTest method setUp.

@Before
public void setUp() throws Exception {
    console = new TestingConsole();
    workdir = Files.createTempDirectory("workdir");
    RemoteFileOptions options = new RemoteFileOptions();
    options.transport = () -> transport;
    OptionsBuilder optionsBuilder = new OptionsBuilder().setConsole(console);
    optionsBuilder.remoteFile = options;
    skylark = new SkylarkTestExecutor(optionsBuilder);
}
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