use of com.google.copybara.testing.DummyRevision in project copybara by google.
the class InfoTest method testInfoUpToDate.
@Test
public void testInfoUpToDate() throws Exception {
info = new InfoCmd((configPath, sourceRef) -> new ConfigLoader(skylark.createModuleSet(), skylark.createConfigFile("copy.bara.sky", configInfo), optionsBuilder.general.getStarlarkMode()) {
@Override
public Config load(Console console) {
return config;
}
@Override
public ConfigWithDependencies loadWithDependencies(Console console) {
return configWithDeps;
}
}, getFakeContextProvider());
MigrationReference<DummyRevision> workflow = MigrationReference.create("workflow", new DummyRevision("1111"), ImmutableList.of());
Info<?> mockedInfo = Info.create(dummyOriginDescription, dummyDestinationDescription, ImmutableList.of(workflow));
Mockito.<Info<? extends Revision>>when(migration.getInfo()).thenReturn(mockedInfo);
info.run(new CommandEnv(temp, optionsBuilder.build(), ImmutableList.of("copy.bara.sky", "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.testing.DummyRevision in project copybara by google.
the class WorkflowTest method testDisableCheckout.
@Test
public void testDisableCheckout() throws Exception {
transformations = ImmutableList.of();
extraWorkflowFields = ImmutableList.of("checkout = False");
Workflow<?, ?> workflow = workflow();
DummyRevision head = origin.resolve("HEAD");
workflow.run(workdir, ImmutableList.of("HEAD"));
ProcessedChange change = Iterables.getLast(destination.processed);
assertThat(change.getOriginRef()).isEqualTo(head);
assertThatPath(workdir).containsNoMoreFiles();
}
use of com.google.copybara.testing.DummyRevision in project copybara by google.
the class WorkflowTest method checkAfterAllMigrations.
private void checkAfterAllMigrations(String rev, WorkflowMode mode) throws Exception {
origin.singleFileChange(0, "base commit", "foo.txt", "0");
DummyRevision base = origin.resolve("HEAD");
origin.singleFileChange(1, "first commit", "foo.txt", "1");
origin.singleFileChange(2, "second commit", "foo.txt", "2");
origin.singleFileChange(3, "third commit", "foo.txt", "3");
String config = "" + "def after_all(ctx):\n" + " ctx.destination.message('after_all '" + " + str([e.type + ' ' + e.destination_ref.id for e in ctx.effects]))\n" + "def after(ctx):\n" + " ctx.destination.message('after '" + " + str([e.type + ' ' + e.destination_ref.id for e in ctx.effects]))\n" + "\n" + "core.workflow(\n" + " name = 'default',\n" + " origin = testing.origin(),\n" + " destination = testing.destination(),\n" + " transformations = [],\n" + " mode = \"" + mode.name() + "\",\n" + " authoring = " + authoring + ",\n" + " after_migration = [after],\n" + " after_workflow = [after_all]" + ")\n";
options.setLastRevision(base.asString());
loadConfig(config).getMigration("default").run(workdir, ImmutableList.of(rev));
}
use of com.google.copybara.testing.DummyRevision in project copybara by google.
the class WorkflowTest method testSquashAlreadyMigratedWithForce.
@Test
public void testSquashAlreadyMigratedWithForce() throws Exception {
origin.addSimpleChange(/*timestamp*/
1);
String oldRef = resolveHead();
origin.addSimpleChange(/*timestamp*/
2);
origin.addSimpleChange(/*timestamp*/
3);
includeReleaseNotes = true;
options.setForce(true);
workflow().run(workdir, ImmutableList.of(HEAD));
WriterContext writerContext = new WriterContext("piper_to_github", "TEST", false, new DummyRevision("test"), Glob.ALL_FILES.roots());
assertThat(destination.newWriter(writerContext).getDestinationStatus(Glob.ALL_FILES, origin.getLabelName()).getBaseline()).isEqualTo("3");
workflow().run(workdir, ImmutableList.of(oldRef));
assertThat(destination.newWriter(writerContext).getDestinationStatus(Glob.ALL_FILES, origin.getLabelName()).getBaseline()).isEqualTo("0");
}
use of com.google.copybara.testing.DummyRevision in project copybara by google.
the class FolderDestinationTest method testRelativePaths.
@Test
public void testRelativePaths() throws Exception {
Path dest = Files.createDirectories(Files.createTempDirectory("workdir").resolve("one"));
workdir = Files.createTempDirectory("local_folder");
Files.write(Files.createDirectories(dest.resolve("folder")).resolve("file1.txt"), "foo".getBytes(UTF_8));
Files.write(Files.createDirectories(workdir.resolve("folder")).resolve("file1.txt"), "bar".getBytes(UTF_8));
options.setWorkdirToRealTempDir();
options.folderDestination.localFolder = dest.resolve("../one").toString();
WriterContext writerContext = new WriterContext("not_important", "not_important", false, new DummyRevision("not_important"), Glob.ALL_FILES.roots());
skylark.<FolderDestination>eval("dest", "dest = folder.destination()").newWriter(writerContext).write(TransformResults.of(workdir, new DummyRevision("not_important")), Glob.createGlob(ImmutableList.of("folder/file1.txt"), ImmutableList.of()), options.general.console());
assertThatPath(dest).containsFile("folder/file1.txt", "bar").containsNoMoreFiles();
}
Aggregations