use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class FilterReplaceTest method setup.
@Before
public void setup() throws IOException {
fs = Jimfs.newFileSystem();
checkoutDir = fs.getPath("/");
Files.createDirectories(checkoutDir);
console = new TestingConsole();
options = new OptionsBuilder().setConsole(console);
skylark = new SkylarkTestExecutor(options);
}
use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class MetadataModuleTest method setup.
@Before
public void setup() throws Exception {
options = new OptionsBuilder();
authoring = "authoring.overwrite('" + DEFAULT_AUTHOR + "')";
workdir = Files.createTempDirectory("workdir");
Files.createDirectories(workdir);
origin = new DummyOrigin().setAuthor(ORIGINAL_AUTHOR);
destination = new RecordsProcessCallDestination();
options.setConsole(new TestingConsole());
options.testingOptions.origin = origin;
options.testingOptions.destination = destination;
skylark = new SkylarkTestExecutor(options);
origin.addSimpleChange(0, "first commit\n\nExtended text").setAuthor(FOO_BAR).addSimpleChange(1, "second commit\n\nExtended text").setAuthor(FOO_BAZ).addSimpleChange(2, "third commit\n\nExtended text");
options.setLastRevision("0");
// We don't care about already migrated code
options.setForce(true);
testingConsole = new TestingConsole();
options.setConsole(testingConsole);
}
use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class QuiltTransformationTest method setUp.
@Before
public void setUp() throws IOException {
checkoutDir = Files.createTempDirectory("workdir");
Files.createDirectories(checkoutDir);
console = new TestingConsole();
// QuiltTransformation needs to write and read from to real temp directory.
options = new OptionsBuilder().setWorkdirToRealTempDir();
// GeneralOptions.getDirFactory() requires $HOME to be set. We set --output-root instead.
options.setOutputRootToTmpDir();
patchingOptions = options.build().get(PatchingOptions.class);
patchingOptions.quiltBin = setUpQuiltBin(patchingOptions.getGeneralOptions());
skylark = new SkylarkTestExecutor(options);
ImmutableMap<String, byte[]> configFiles = ImmutableMap.of("patches/diff.patch", OLDDIFF.getBytes(UTF_8), "patches/series", SERIES.getBytes(UTF_8));
patchFile = new MapConfigFile(configFiles, "patches/diff.patch");
seriesFile = new MapConfigFile(configFiles, "patches/series");
}
use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class ConsoleTest method fmtMethodsWork.
@Test
public void fmtMethodsWork() throws Exception {
TestingConsole delegate = new TestingConsole().respondYes();
CapturingConsole console = CapturingConsole.captureAllConsole(delegate);
console.errorFmt("This is %s", "error!");
console.warnFmt("This is %s", "warning");
console.infoFmt("This is %s", "info");
console.progressFmt("This is %s", "progress");
assertThat(console.promptConfirmationFmt("Do you want to %s?", "continue")).isTrue();
assertThat(console.getMessages()).containsExactly(new Message(MessageType.ERROR, "This is error!"), new Message(MessageType.WARNING, "This is warning"), new Message(MessageType.INFO, "This is info"), new Message(MessageType.PROGRESS, "This is progress"));
}
use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class DelegateConsoleTest method testConsole.
@Test
public void testConsole() {
TestingConsole delegate = new TestingConsole();
List<Message> messages = new ArrayList<>();
DelegateConsole delegating = new DelegateConsole(delegate) {
@Override
protected void handleMessage(MessageType type, String message) {
messages.add(new Message(type, message));
}
};
delegating.startupMessage("v1");
delegating.info("This is info");
delegating.warn("This is warning");
delegating.error("This is error");
delegating.verbose("This is verbose");
delegating.progress("This is progress");
assertThat(messages).containsExactly(new Message(MessageType.INFO, "Copybara source mover (Version: v1)"), new Message(MessageType.INFO, "This is info"), new Message(MessageType.WARNING, "This is warning"), new Message(MessageType.ERROR, "This is error"), new Message(MessageType.VERBOSE, "This is verbose"), new Message(MessageType.PROGRESS, "This is progress"));
delegate.assertThat().matchesNext(MessageType.INFO, "Copybara source mover [(]Version: v1[)]").matchesNext(MessageType.INFO, "This is info").matchesNext(MessageType.WARNING, "This is warning").matchesNext(MessageType.ERROR, "This is error").matchesNext(MessageType.VERBOSE, "This is verbose").matchesNext(MessageType.PROGRESS, "This is progress");
}
Aggregations