use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class GitDestinationTest method processUserAborts.
@Test
public void processUserAborts() throws Exception {
console = new TestingConsole().respondNo();
fetch = "master";
push = "master";
Files.write(workdir.resolve("test.txt"), "some content".getBytes());
thrown.expect(ValidationException.class);
thrown.expectMessage("User aborted execution: did not confirm diff changes");
processWithBaselineAndConfirmation(firstCommitWriter(), new DummyRevision("origin_ref"), /*baseline=*/
null, /*askForConfirmation=*/
true);
}
use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class GitDestinationTest method processEmptyDiff.
@Test
public void processEmptyDiff() throws Exception {
console = new TestingConsole().respondYes();
fetch = "master";
push = "master";
Files.write(workdir.resolve("test.txt"), "some content".getBytes());
processWithBaselineAndConfirmation(firstCommitWriter(), new DummyRevision("origin_ref1"), /*baseline=*/
null, /*askForConfirmation=*/
true);
thrown.expect(EmptyChangeException.class);
// process empty change. Shouldn't ask anything.
processWithBaselineAndConfirmation(newWriter(), new DummyRevision("origin_ref2"), /*baseline=*/
null, /*askForConfirmation=*/
true);
}
use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class GitOriginSubmodulesTest method setup.
@Before
public void setup() throws Exception {
OptionsBuilder options = new OptionsBuilder().setConsole(new TestingConsole()).setOutputRootToTmpDir();
skylark = new SkylarkTestExecutor(options, GitModule.class);
// Pass custom HOME directory so that we run an hermetic test and we
// can add custom configuration to $HOME/.gitconfig.
Path userHomeForTest = Files.createTempDirectory("home");
options.setHomeDir(userHomeForTest.toString());
checkoutDir = Files.createTempDirectory("checkout");
}
use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class GitOriginTest method testGitUrlOverwrite.
/**
* Check that we can overwrite the git url using the CLI option and that we show a message
*/
@Test
public void testGitUrlOverwrite() throws Exception {
createTestRepo(Files.createTempDirectory("cliremote"));
git("init");
Files.write(remote.resolve("cli_remote.txt"), "some change".getBytes(UTF_8));
repo.add().files("cli_remote.txt").run();
git("commit", "-m", "a change from somewhere");
TestingConsole testConsole = new TestingConsole();
options.setConsole(testConsole);
origin = origin();
String newUrl = "file://" + remote.toFile().getAbsolutePath();
Reader<GitRevision> reader = newReader();
Change<GitRevision> cliHead = reader.change(origin.resolve(newUrl));
reader.checkout(cliHead.getRevision(), checkoutDir);
assertThat(cliHead.firstLineMessage()).isEqualTo("a change from somewhere");
assertThatPath(checkoutDir).containsFile("cli_remote.txt", "some change").containsNoMoreFiles();
testConsole.assertThat().onceInLog(MessageType.WARNING, "Git origin URL overwritten in the command line as " + newUrl);
}
use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class GitOriginTest method setup.
@Before
public void setup() throws Exception {
options = new OptionsBuilder();
console = new TestingConsole();
options = new OptionsBuilder().setConsole(console).setOutputRootToTmpDir();
skylark = new SkylarkTestExecutor(options, GitModule.class);
// Pass custom HOME directory so that we run an hermetic test and we
// can add custom configuration to $HOME/.gitconfig.
Path userHomeForTest = Files.createTempDirectory("home");
options.setEnvironment(GitTestUtil.getGitEnv());
options.setHomeDir(userHomeForTest.toString());
createTestRepo(Files.createTempDirectory("remote"));
checkoutDir = Files.createTempDirectory("checkout");
url = "file://" + remote.toFile().getAbsolutePath();
ref = "other";
moreOriginArgs = "";
origin = origin();
Files.write(remote.resolve("test.txt"), "some content".getBytes(UTF_8));
repo.add().files("test.txt").run();
git("commit", "-m", "first file", "--date", commitTime);
firstCommitRef = repo.parseRef("HEAD");
originFiles = Glob.ALL_FILES;
}
Aggregations