use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class WorkflowTest method testTestWorkflowWithDiffInOrigin.
@Test
public void testTestWorkflowWithDiffInOrigin() throws Exception {
GitRepository remote = GitRepository.newBareRepo(Files.createTempDirectory("gitdir"), getGitEnv(), /*verbose=*/
true, DEFAULT_TIMEOUT, /*noVerify=*/
false).withWorkTree(workdir);
remote.init();
String primaryBranch = remote.getPrimaryBranch();
Files.write(workdir.resolve("foo.txt"), new byte[] {});
remote.add().files("foo.txt").run();
remote.simpleCommand("commit", "foo.txt", "-m", "message_a");
GitRevision lastRev = remote.resolveReference(primaryBranch);
Files.write(workdir.resolve("bar.txt"), "change content".getBytes(UTF_8));
remote.add().files("bar.txt").run();
remote.simpleCommand("commit", "bar.txt", "-m", "message_s");
TestingConsole testingConsole = new TestingConsole().respondYes();
options.workflowOptions.lastRevision = lastRev.getSha1();
options.setWorkdirToRealTempDir().setConsole(testingConsole).setHomeDir(StandardSystemProperty.USER_HOME.value());
Workflow<?, ?> workflow = (Workflow<?, ?>) new SkylarkTestExecutor(options).loadConfig("core.workflow(\n" + " name = 'foo',\n" + " origin = git.origin(url='" + remote.getGitDir() + "',\n" + " ref = '" + primaryBranch + "'\n" + " ),\n" + " destination = folder.destination(),\n" + " mode = 'ITERATIVE',\n" + " authoring = " + authoring + ",\n" + " transformations = [metadata.replace_message(''),],\n" + ")\n").getMigration("foo");
workflow.getWorkflowOptions().diffInOrigin = true;
workflow.run(workdir, ImmutableList.of(primaryBranch));
testingConsole.assertThat().onceInLog(MessageType.WARNING, "Change 1 of 1 \\(.*\\)\\: Continue to migrate with '" + workflow.getMode() + "'" + " to " + workflow.getDestination().getType() + "\\?");
}
use of com.google.copybara.util.console.testing.TestingConsole 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.util.console.testing.TestingConsole 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.util.console.testing.TestingConsole in project copybara by google.
the class ApiCheckerTest method testCheckInternalError.
@Test
public void testCheckInternalError() throws CheckerException {
ApiChecker checker = new ApiChecker(new FakeChecker() {
@Override
public void doCheck(ImmutableMap<String, String> fields, Console console) throws IOException {
throw new IOException("Tool error!");
}
}, new TestingConsole());
RuntimeException e1 = assertThrows(RuntimeException.class, () -> checker.check("foo", new Object()));
assertThat(e1).hasMessageThat().isEqualTo("Error running checker");
RuntimeException e2 = assertThrows(RuntimeException.class, () -> checker.check("foo", new Object(), "bar", new Object()));
assertThat(e2).hasMessageThat().isEqualTo("Error running checker");
RuntimeException e3 = assertThrows(RuntimeException.class, () -> checker.check("foo", new Object(), "bar", new Object(), "baz", new Object()));
assertThat(e3).hasMessageThat().isEqualTo("Error running checker");
}
use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class ApiCheckerTest method testCheck.
@Test
public void testCheck() throws CheckerException {
ApiChecker checker = new ApiChecker(new FakeChecker() {
@Override
public void doCheck(ImmutableMap<String, String> fields, Console console) {
}
}, new TestingConsole());
checker.check("foo", new Object());
checker.check("foo", new Object(), "bar", new Object());
checker.check("foo", new Object(), "bar", new Object(), "baz", new Object());
}
Aggregations