use of com.google.copybara.Transformation 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.Transformation 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>'");
}
Aggregations