Search in sources :

Example 16 with Config

use of com.google.copybara.config.Config in project copybara by google.

the class WorkflowTest method customIdentity_customPathIncluded.

@Test
public void customIdentity_customPathIncluded() throws Exception {
    options.workflowOptions.initHistory = true;
    byte[] cfgContent = ("" + "core.workflow(\n" + "    name = 'default',\n" + "    authoring = " + authoring + "\n," + "    origin = testing.origin(),\n" + "    destination = testing.destination(),\n" + "    change_identity = '${copybara_config_path}foo${label:some_label}',\n" + "    mode = 'ITERATIVE',\n" + ")\n\n" + "").getBytes(UTF_8);
    Config config1 = skylark.loadConfig(new MapConfigFile(ImmutableMap.of("foo/copy.bara.sky", cfgContent), "foo/copy.bara.sky"));
    Config config2 = skylark.loadConfig(new MapConfigFile(ImmutableMap.of("bar/copy.bara.sky", cfgContent), "bar/copy.bara.sky"));
    origin.addSimpleChange(1, "change\n\nsome_label=a");
    config1.getMigration("default").run(workdir, ImmutableList.of());
    ImmutableList<String> oneResult = destination.processed.stream().map(ProcessedChange::getChangeIdentity).collect(ImmutableList.toImmutableList());
    destination.processed.clear();
    config2.getMigration("default").run(workdir, ImmutableList.of());
    ImmutableList<String> twoResult = destination.processed.stream().map(ProcessedChange::getChangeIdentity).collect(ImmutableList.toImmutableList());
    assertThat(oneResult).isNotEqualTo(twoResult);
}
Also used : Config(com.google.copybara.config.Config) MapConfigFile(com.google.copybara.config.MapConfigFile) Test(org.junit.Test)

Example 17 with Config

use of com.google.copybara.config.Config in project copybara by google.

the class MetadataModuleTest method createWorkflow.

private Workflow<?, ?> createWorkflow(WorkflowMode mode, String... transforms) throws IOException, ValidationException {
    passThruAuthoring();
    Config config = loadConfig("" + "core.workflow(\n" + "    name = 'default',\n" + "    origin =  testing.origin(),\n" + "    authoring = " + authoring + "\n," + "    destination = testing.destination(),\n" + "    mode = '" + mode + "',\n" + "    transformations = [" + Joiner.on(", ").join(transforms) + "]\n" + ")\n");
    return (Workflow) config.getMigration("default");
}
Also used : Config(com.google.copybara.config.Config) Workflow(com.google.copybara.Workflow)

Aggregations

Config (com.google.copybara.config.Config)17 ValidationException (com.google.copybara.exception.ValidationException)8 Console (com.google.copybara.util.console.Console)8 Test (org.junit.Test)8 Migration (com.google.copybara.config.Migration)7 IOException (java.io.IOException)5 ImmutableList (com.google.common.collect.ImmutableList)4 MigrationReference (com.google.copybara.Info.MigrationReference)4 Author (com.google.copybara.authoring.Author)4 DummyRevision (com.google.copybara.testing.DummyRevision)4 OptionsBuilder (com.google.copybara.testing.OptionsBuilder)4 TestingEventMonitor (com.google.copybara.testing.TestingEventMonitor)4 MessageType (com.google.copybara.util.console.Message.MessageType)4 TestingConsole (com.google.copybara.util.console.testing.TestingConsole)4 Path (java.nio.file.Path)4 Before (org.junit.Before)4 ImmutableListMultimap (com.google.common.collect.ImmutableListMultimap)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 ImmutableMultimap (com.google.common.collect.ImmutableMultimap)3 Truth.assertThat (com.google.common.truth.Truth.assertThat)3