use of com.google.copybara.exception.ValidationException in project copybara by google.
the class GitOriginTest method testInvalidGithubUrl.
@Test
public void testInvalidGithubUrl() throws Exception {
ValidationException expected = assertThrows(ValidationException.class, () -> skylark.eval("result", "result = git.github_origin(\n" + " url = 'https://foo.com/copybara',\n" + " ref = 'main',\n" + ")"));
console.assertThat().onceInLog(MessageType.ERROR, ".*Invalid Github URL: https://foo.com/copybara.*");
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class GitOriginTest method testInvalidGithubUrlWithGithubString.
@Test
public void testInvalidGithubUrlWithGithubString() throws Exception {
ValidationException expected = assertThrows(ValidationException.class, () -> skylark.eval("result", "result = git.github_origin(\n" + " url = 'https://foo.com/github.com',\n" + " ref = 'main',\n" + ")"));
console.assertThat().onceInLog(MessageType.ERROR, ".*Invalid Github URL: https://foo.com/github.com.*");
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class GitOriginTest method partialFetchFailsWithFetchingTheWholeRepo.
@Test
public void partialFetchFailsWithFetchingTheWholeRepo() throws Exception {
RecordsProcessCallDestination destination = new RecordsProcessCallDestination();
options.testingOptions.destination = destination;
options.setLastRevision(firstCommitRef);
@SuppressWarnings("unchecked") Workflow<GitRevision, Revision> wf = (Workflow<GitRevision, Revision>) skylark.loadConfig("" + "core.workflow(\n" + " name = 'default',\n" + " origin = git.origin(\n" + " url = '" + url + "',\n" + " include_branch_commit_logs = True,\n" + " partial_fetch = True,\n" + " ),\n" + " origin_files = glob(['**']),\n" + " destination = testing.destination(),\n" + " authoring = authoring.pass_thru('example <example@example.com>'),\n" + ")\n").getMigration("default");
ValidationException repoException = assertThrows(ValidationException.class, () -> wf.run(Files.createTempDirectory("foo"), ImmutableList.of("HEAD")));
assertThat(repoException).hasMessageThat().contains("Config error: partial_fetch feature is not compatible with fetching the whole repo.");
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class GitHubHostTest method testGetProjectNameFromUrl.
@Test
public void testGetProjectNameFromUrl() throws Exception {
assertThat(GITHUB_COM.getProjectNameFromUrl("https://github.com/foo")).isEqualTo("foo");
assertThat(GITHUB_COM.getProjectNameFromUrl("http://github.com/foo")).isEqualTo("foo");
assertThat(GITHUB_COM.getProjectNameFromUrl("https://github.com/foo/bar")).isEqualTo("foo/bar");
assertThat(GITHUB_COM.getProjectNameFromUrl("http://github.com/foo/bar")).isEqualTo("foo/bar");
assertThat(GITHUB_COM.getProjectNameFromUrl("http://github.com/foo/bar/foobar")).isEqualTo("foo/bar");
assertThat(GITHUB_COM.getProjectNameFromUrl("ssh://git@github.com/foo/bar.git")).isEqualTo("foo/bar");
assertThat(GITHUB_COM.getProjectNameFromUrl("git@github.com/foo/bar.git")).isEqualTo("foo/bar");
assertThat(GITHUB_COM.getProjectNameFromUrl("git@github.com:foo/bar.git")).isEqualTo("foo/bar");
ValidationException noProject = assertThrows(ValidationException.class, () -> GITHUB_COM.getProjectNameFromUrl("foo@bar:baz"));
assertThat(noProject).hasMessageThat().contains("Cannot find project name");
ValidationException notGitHub = assertThrows(ValidationException.class, () -> GITHUB_COM.getProjectNameFromUrl("file://some/local/dir"));
assertThat(notGitHub).hasMessageThat().contains("Not a github url");
ValidationException noUrl = assertThrows(ValidationException.class, () -> GITHUB_COM.getProjectNameFromUrl(""));
assertThat(noUrl).hasMessageThat().contains("Empty url");
// While www.github.com is a valid host, we prefer the non-www version for consistency.
assertThat(assertThrows(ValidationException.class, () -> GITHUB_COM.getProjectNameFromUrl("https://www.github.com/foo"))).hasMessageThat().contains("Expected host: github.com");
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class HgRepositoryTest method testPullInvalidPath.
@Test
public void testPullInvalidPath() throws Exception {
String invalidPath = "/not/a/path";
ValidationException e = assertThrows(ValidationException.class, () -> repository.pullAll(invalidPath));
assertThat(e).hasMessageThat().contains("Repository not found");
}
Aggregations