use of com.google.copybara.testing.SkylarkTestExecutor 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);
}
use of com.google.copybara.testing.SkylarkTestExecutor 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);
}
use of com.google.copybara.testing.SkylarkTestExecutor in project copybara by google.
the class ReplaceTest 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);
}
use of com.google.copybara.testing.SkylarkTestExecutor in project copybara by google.
the class TodoReplaceTest method setup.
@Before
public void setup() throws IOException {
FileSystem fs = Jimfs.newFileSystem();
checkoutDir = fs.getPath("/");
Files.createDirectories(checkoutDir);
console = new TestingConsole();
OptionsBuilder options = new OptionsBuilder().setConsole(console);
skylark = new SkylarkTestExecutor(options);
}
use of com.google.copybara.testing.SkylarkTestExecutor in project copybara by google.
the class TransformDebugTest method setup.
@Before
public void setup() throws Exception {
options = new OptionsBuilder();
origin = new DummyOrigin();
destination = new RecordsProcessCallDestination();
options.testingOptions.origin = origin;
options.testingOptions.destination = destination;
skylark = new SkylarkTestExecutor(options);
workdir = Files.createTempDirectory("workdir");
options.setHomeDir(Files.createTempDirectory("home").toString());
options.setWorkdirToRealTempDir();
console = Mockito.mock(Console.class);
when(console.colorize(any(), anyString())).thenAnswer((Answer<String>) invocationOnMock -> (String) invocationOnMock.getArguments()[1]);
}
Aggregations