use of com.google.copybara.TransformWork in project copybara by google.
the class MetadataModuleTest method checkLabelChange.
private void checkLabelChange(String msg, String transform, String expectedOutput) throws Exception {
TransformWork tw = TransformWorks.of(workdir, msg, testingConsole).withChanges(new Changes(ImmutableList.of(toChange(new DummyRevision("1").withLabels(ImmutableListMultimap.of("FROM_CHANGE", "from_change_value")), ORIGINAL_AUTHOR)), ImmutableList.of())).withResolvedReference(new DummyRevision("123").withLabels(ImmutableListMultimap.of("SOME", "value")));
Transformation t = skylark.eval("t", "t = " + transform);
t.transform(tw);
assertThat(tw.getMessage()).isEqualTo(expectedOutput);
}
use of com.google.copybara.TransformWork in project copybara by google.
the class MetadataModuleTest method testMapAuthor_reverseFaiIfNotFound.
@Test
public void testMapAuthor_reverseFaiIfNotFound() throws Exception {
Transformation m = skylark.eval("m", "m = " + "metadata.map_author({\n" + " 'a <a@example.com>' : 'b <b@example.com>',\n" + "}," + "reversible = True, reverse_fail_if_not_found = True)");
TransformWork work = TransformWorks.of(workdir, "test", testingConsole);
work.setAuthor(new Author("x", "x@example.com"));
// normal workflow works:
m.transform(work);
ValidationException thrown = assertThrows(ValidationException.class, () -> m.reverse().transform(work));
assertThat(thrown).hasMessageThat().contains("Cannot find a mapping for author 'x <x@example.com>'");
}
use of com.google.copybara.TransformWork in project copybara by google.
the class RevisionMigratorTest method testOldReferenceGetsNotUpdated.
@Test
public void testOldReferenceGetsNotUpdated() throws Exception {
String desc = "This is an awesome change, building on http://internalReviews.com/110";
TransformWork work = getTransformWork(desc);
referenceMigrator.transform(work);
assertThat(work.getMessage()).isEqualTo("This is an awesome change, building on http://internalReviews.com/110");
}
use of com.google.copybara.TransformWork in project copybara by google.
the class RevisionMigratorTest method testReferenceGetsUpdated.
@Test
public void testReferenceGetsUpdated() throws Exception {
String desc = "This is an awesome change, building on http://internalReviews.com/123";
TransformWork work = getTransformWork(desc);
referenceMigrator.transform(work);
assertThat(work.getMessage()).isEqualTo("This is an awesome change, building on http://externalreviews.com/view?7b");
}
use of com.google.copybara.TransformWork in project copybara by google.
the class RevisionMigratorTest method testLegacyLabel.
@Test
public void testLegacyLabel() throws Exception {
referenceMigrator = ReferenceMigrator.create("http://internalReviews.com/${reference}", "http://externalreviews.com/view?${reference}", Pattern.compile("[0-9]+"), Pattern.compile("[0-9a-f]+"), ImmutableList.of("LegacyImporter"), location);
String desc = "This is an awesome change, building on http://internalReviews.com/123";
TransformWork work = getTransformWork(desc);
referenceMigrator.transform(work);
assertThat(work.getMessage()).isEqualTo("This is an awesome change, building on http://externalreviews.com/view?7b");
}
Aggregations