use of com.google.copybara.exception.ValidationException in project copybara by google.
the class GitCredentialTest method testNotFound.
@Test
public void testNotFound() throws Exception {
ValidationException expected = assertThrows(ValidationException.class, () -> credential.fill(repoGitDir, "https://somehost.com/foo/bar"));
assertThat(expected).hasMessageThat().contains("Interactive prompting of passwords for git is disabled");
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class GitDestinationTest method testChangeDescriptionEmpty_empty_commit.
@Test
public void testChangeDescriptionEmpty_empty_commit() throws Exception {
fetch = primaryBranch;
push = primaryBranch;
Path scratchTree = Files.createTempDirectory("GitDestinationTest-testLocalRepo");
Files.write(scratchTree.resolve("foo"), "foo\n".getBytes(UTF_8));
repo().withWorkTree(scratchTree).add().force().files("foo").run();
repo().withWorkTree(scratchTree).simpleCommand("commit", "-a", "-m", "change");
DummyRevision originRef = new DummyRevision("origin_ref");
WriterContext writerContext = new WriterContext("GitDestinationTest", "test", true, new DummyRevision("origin_ref1"), Glob.ALL_FILES.roots());
Writer<GitRevision> writer = destination().newWriter(writerContext);
ValidationException e = assertThrows(EmptyChangeException.class, () -> writer.write(TransformResults.of(workdir, originRef).withSummary("").withLabelFinder(s -> ImmutableList.of()).withSetRevId(false), Glob.createGlob(ImmutableList.of("nothing_to_be_found"), ImmutableList.of("test.txt")), console));
assertThat(e).hasMessageThat().contains("Migration of the revision resulted in an empty change");
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class GitDestinationTest method processFetchRefDoesntExist.
@Test
public void processFetchRefDoesntExist() throws Exception {
fetch = "testPullFromRef";
push = "testPushToRef";
Files.write(workdir.resolve("test.txt"), "some content".getBytes(UTF_8));
ValidationException thrown = assertThrows(ValidationException.class, () -> process(newWriter(), new DummyRevision("origin_ref")));
assertThat(thrown).hasMessageThat().contains("'refs/heads/testPullFromRef' doesn't exist");
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class GitDestinationTest method processUserAborts.
@Test
public void processUserAborts() throws Exception {
console = new TestingConsole().respondNo();
fetch = primaryBranch;
push = primaryBranch;
Files.write(workdir.resolve("test.txt"), "some content".getBytes(UTF_8));
ValidationException thrown = assertThrows(ValidationException.class, () -> processWithBaselineAndConfirmation(firstCommitWriter(), destinationFiles, new DummyRevision("origin_ref"), /*baseline=*/
null, /*askForConfirmation=*/
true));
assertThat(thrown).hasMessageThat().contains("User aborted execution: did not confirm diff changes");
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class GitDestinationTest method gitUserEmailMustBeConfigured.
@Test
public void gitUserEmailMustBeConfigured() throws Exception {
options.gitDestination.committerName = "Foo Bara";
options.gitDestination.committerEmail = "";
fetch = primaryBranch;
push = primaryBranch;
ValidationException thrown = assertThrows(ValidationException.class, () -> process(firstCommitWriter(), new DummyRevision("first_commit")));
assertThat(thrown).hasMessageThat().contains("'user.name' and/or 'user.email' are not configured.");
}
Aggregations