use of com.google.copybara.config.ConfigValidator in project copybara by google.
the class CopybaraTest method testInfoUpToDate.
@Test
public void testInfoUpToDate() throws Exception {
MigrationReference<DummyRevision> workflow = MigrationReference.create("workflow", new DummyRevision("1111"), ImmutableList.of());
Info<? extends Revision> mockedInfo = Info.create(ImmutableList.of(workflow));
Mockito.<Info<? extends Revision>>when(migration.getInfo()).thenReturn(mockedInfo);
Copybara copybara = new Copybara(new ConfigValidator() {
}, migration -> {
}, /*configLoaderProvider=*/
null);
copybara.info(optionsBuilder.build(), config, "workflow");
assertThat(eventMonitor.infoFinishedEvent).isNotNull();
assertThat(eventMonitor.infoFinishedEvent.getInfo()).isEqualTo(mockedInfo);
console.assertThat().onceInLog(MessageType.INFO, ".*last_migrated 1111 - last_available None.*");
}
use of com.google.copybara.config.ConfigValidator in project copybara by google.
the class Main method getCommands.
public ImmutableSet<CopybaraCmd> getCommands(ModuleSet moduleSet, ConfigLoaderProvider configLoaderProvider, JCommander jcommander) throws CommandLineException {
ConfigValidator validator = getConfigValidator(moduleSet.getOptions());
Consumer<Migration> consumer = getMigrationRanConsumer();
return ImmutableSet.of(new MigrateCmd(validator, consumer, configLoaderProvider, moduleSet), new InfoCmd(configLoaderProvider, newInfoContextProvider()), new ValidateCmd(validator, consumer, configLoaderProvider), new HelpCmd(jcommander), new OnboardCmd(), new VersionCmd());
}
use of com.google.copybara.config.ConfigValidator in project copybara by google.
the class ReadConfigFromChangeWorkflowTest method testWriterStateMaintained.
/**
* A test that check that we can mutate the glob in iterative mode
*/
@SuppressWarnings("unchecked")
@Test
public void testWriterStateMaintained() throws Exception {
options.workflowOptions.lastRevision = "0";
String configCode = mutatingWorkflow("*");
Config cfg = skylark.loadConfig(configCode);
ConfigLoader constantConfigLoader = new ConfigLoader(skylark.createModuleSet(), skylark.createConfigFile("copy.bara.sky", configCode), options.general.getStarlarkMode()) {
@Override
protected Config doLoadForRevision(Console console, Revision revision) throws ValidationException {
try {
return skylark.loadConfig(mutatingWorkflow(revision.asString()));
} catch (IOException e) {
throw new AssertionError("Should not fail", e);
}
}
};
ReadConfigFromChangeWorkflow<?, ?> wf = new ReadConfigFromChangeWorkflow<>((Workflow) cfg.getMigration("default"), options.build(), constantConfigLoader, new ConfigValidator() {
@Override
public ValidationResult validate(Config config, String migrationName) {
return ValidationResult.EMPTY;
}
});
origin.singleFileChange(0, "base", "fileB", "b");
origin.singleFileChange(1, "one", "file1", "b");
origin.singleFileChange(2, "two", "file2", "b");
origin.singleFileChange(3, "three", "file3", "b");
wf.run(Files.createTempDirectory("workdir"), ImmutableList.of("3"));
assertThat(destination.processed).hasSize(3);
assertThat(destination.processed.get(0).getDestinationFiles().toString()).contains("file1");
assertThat(destination.processed.get(0).getWorkdir()).containsExactly("file1", "b");
assertThat(destination.processed.get(1).getDestinationFiles().toString()).contains("file2");
assertThat(destination.processed.get(1).getWorkdir()).containsExactly("file2", "b");
assertThat(destination.processed.get(2).getDestinationFiles().toString()).contains("file3");
assertThat(destination.processed.get(2).getWorkdir()).containsExactly("file3", "b");
}
use of com.google.copybara.config.ConfigValidator in project copybara by google.
the class CopybaraTest method testInfoAvailableToMigrate.
@Test
public void testInfoAvailableToMigrate() throws Exception {
MigrationReference<DummyRevision> workflow = MigrationReference.create("workflow", new DummyRevision("1111"), ImmutableList.of(newChange("2222"), newChange("3333")));
Info<? extends Revision> mockedInfo = Info.create(ImmutableList.of(workflow));
Mockito.<Info<? extends Revision>>when(migration.getInfo()).thenReturn(mockedInfo);
Copybara copybara = new Copybara(new ConfigValidator() {
}, migration -> {
}, /*configLoaderProvider=*/
null);
copybara.info(optionsBuilder.build(), config, "workflow");
assertThat(eventMonitor.infoFinishedEvent).isNotNull();
assertThat(eventMonitor.infoFinishedEvent.getInfo()).isEqualTo(mockedInfo);
console.assertThat().onceInLog(MessageType.INFO, ".*last_migrated 1111 - last_available 3333.*");
}
Aggregations