use of com.google.copybara.testing.SkylarkTestExecutor in project copybara by google.
the class BuildozerBatchTest method setup.
@Before
public void setup() throws IOException {
console = new TestingConsole();
options = new OptionsBuilder();
options.setConsole(console);
BuildozerTesting.enable(options);
checkoutDir = Files.createTempDirectory("BuildozerBatchTest-" + name.getMethodName());
skylark = new SkylarkTestExecutor(options);
}
use of com.google.copybara.testing.SkylarkTestExecutor in project copybara by google.
the class BuildozerDeleteTest method setup.
@Before
public void setup() throws Exception {
console = new TestingConsole();
options = new OptionsBuilder();
options.setConsole(console);
BuildozerTesting.enable(options);
checkoutDir = Files.createTempDirectory("BuildozerDeleteTest");
skylark = new SkylarkTestExecutor(options);
}
use of com.google.copybara.testing.SkylarkTestExecutor in project copybara by google.
the class SkylarkParserTest method setup.
@Before
public void setup() {
options = new OptionsBuilder();
console = new TestingConsole();
options.setConsole(console);
options.general.starlarkMode = StarlarkMode.STRICT.name();
parser = new SkylarkTestExecutor(options).withStaticModules(ImmutableSet.of(Mock.class, MockLabelsAwareModule.class));
}
use of com.google.copybara.testing.SkylarkTestExecutor in project copybara by google.
the class SkylarkParserTest method testStrictStarlarkParsingCatchesError.
@Test
public void testStrictStarlarkParsingCatchesError() throws IOException, ValidationException {
// A parse error is always reported, even in LOOSE mode.
options.general.starlarkMode = StarlarkMode.LOOSE.name();
parser = new SkylarkTestExecutor(options);
ValidationException ex = assertThrows(ValidationException.class, () -> parser.loadConfig("foo = '\\j',"));
assertThat(ex).hasMessageThat().contains("Trailing comma");
// Strict mode detects string escapes, if/for at top level, and loads not at the top.
options.general.starlarkMode = StarlarkMode.STRICT.name();
parser = new SkylarkTestExecutor(options);
ex = assertThrows(ValidationException.class, () -> parser.loadConfig("foo = '\\j',"));
assertThat(ex).hasMessageThat().contains("Trailing comma");
assertThat(ex).hasMessageThat().contains("invalid escape sequence");
}
use of com.google.copybara.testing.SkylarkTestExecutor in project copybara by google.
the class GerritDestinationTest method setup.
@Before
public void setup() throws Exception {
workdir = Files.createTempDirectory("workdir");
console = new TestingConsole();
options = new OptionsBuilder().setConsole(console).setOutputRootToTmpDir();
gitUtil = new GitTestUtil(options);
Path credentialsFile = Files.createTempFile("credentials", "test");
Files.write(credentialsFile, BASE_URL.getBytes(UTF_8));
GitRepository repo = newBareRepo(Files.createTempDirectory("test_repo"), getGitEnv(), /*verbose=*/
true, DEFAULT_TIMEOUT, /*noVerify=*/
false).init().withCredentialHelper("store --file=" + credentialsFile);
gitUtil.mockRemoteGitRepos(new Validator(), repo);
options.gitDestination = new GitDestinationOptions(options.general, options.git);
options.gitDestination.committerEmail = "commiter@email";
options.gitDestination.committerName = "Bara Kopi";
excludedDestinationPaths = ImmutableList.of();
repoGitDir = gitUtil.mockRemoteRepo("localhost:33333/foo/bar").getGitDir();
url = "https://localhost:33333/foo/bar";
repo().init();
skylark = new SkylarkTestExecutor(options);
when(gitUtil.httpTransport().buildRequest(eq("GET"), startsWith("https://localhost:33333/changes/"))).then((Answer<LowLevelHttpRequest>) invocation -> {
String change = changeIdFromRequest((String) invocation.getArguments()[1]);
return mockResponse("[" + "{" + " change_id : \"" + change + "\"," + " status : \"NEW\"" + "}]");
});
gitUtil.mockApi(eq("GET"), eq("https://localhost:33333/changes/?q=" + "hashtag:%22copybara_id_origin_ref_commiter@email%22%20AND" + "%20project:foo/bar%20AND%20status:NEW"), mockResponse("[]"));
}
Aggregations