use of com.google.copybara.authoring.Author in project copybara by google.
the class RemoteArchiveOriginTest method testZipFileMultipleDirs.
@Test
public void testZipFileMultipleDirs() throws Exception {
when(transport.open(any())).thenReturn(new ByteArrayInputStream(BaseEncoding.base64().decode(CAPTURED_MULTIPLE_DIRS_ZIP_FILE)));
RemoteArchiveOrigin underTest = new RemoteArchiveOrigin("zip", Author.parse("Copybara <noreply@copybara.io>"), "a message", transport, profiler, remoteFileOptions);
Reader<RemoteArchiveRevision> reader = underTest.newReader(Glob.ALL_FILES, new Authoring(new Author("foo", "default@example.com"), AuthoringMappingMode.PASS_THRU, ImmutableSet.of()));
RemoteArchiveRevision revision = underTest.resolve("https://dirs.zip");
reader.checkout(revision, workdir);
assertThatPath(workdir).containsFile("parent/dir-one/first.txt", "first file\n");
assertThatPath(workdir).containsFile("parent/dir-two/second.txt", "second file\n");
}
use of com.google.copybara.authoring.Author in project copybara by google.
the class DummyOriginTest method canSetAuthorOfIndividualChanges.
@Test
public void canSetAuthorOfIndividualChanges() throws Exception {
DummyOrigin origin = new DummyOrigin().setAuthor(new Author("Dummy Origin", "dummy_origin@google.com")).addSimpleChange(/*timestamp*/
42).setAuthor(new Author("Wise Origin", "wise_origin@google.com")).addSimpleChange(/*timestamp*/
999);
Authoring authoring = new Authoring(new Author("foo", "default.example.com"), AuthoringMappingMode.PASS_THRU, ImmutableSet.of());
ImmutableList<Change<DummyRevision>> changes = origin.newReader(Glob.ALL_FILES, authoring).changes(/*fromRef*/
null, /*toRef*/
origin.resolve("1")).getChanges();
assertThat(changes).hasSize(2);
assertThat(changes.get(0).getAuthor()).isEqualTo(new Author("Dummy Origin", "dummy_origin@google.com"));
assertThat(changes.get(1).getAuthor()).isEqualTo(new Author("Wise Origin", "wise_origin@google.com"));
}
use of com.google.copybara.authoring.Author in project copybara by google.
the class RemoteFileModuleTest method testRemoteArchiveOriginZipFile.
@Test
public void testRemoteArchiveOriginZipFile() throws Exception {
when(transport.open(any())).thenReturn(new ByteArrayInputStream(BaseEncoding.base64().decode(CAPUTRED_HELLO_WORLD_ZIP_FILE)));
RemoteArchiveOrigin underTest = skylark.eval("o", "o = remotefiles.origin(unpack_method = 'zip', message = 'hello world')");
Reader<RemoteArchiveRevision> reader = underTest.newReader(Glob.ALL_FILES, new Authoring(new Author("foo", "default@example.com"), AuthoringMappingMode.PASS_THRU, ImmutableSet.of()));
RemoteArchiveRevision revision = underTest.resolve("https://dirs.zip");
reader.checkout(revision, workdir);
assertThatPath(workdir).containsFile("test.txt", "hello world\n");
}
use of com.google.copybara.authoring.Author in project copybara by google.
the class MetadataModuleTest method testMapAuthor_failIfNotFound.
@Test
public void testMapAuthor_failIfNotFound() throws Exception {
options.setLastRevision(origin.resolve("HEAD").asString());
Workflow<?, ?> wf = createWorkflow(WorkflowMode.ITERATIVE, "" + "metadata.map_author({\n" + " 'a' : 'x <x@example.com>',\n" + " 'b@example.com' : 'y <y@example.com>',\n" + " 'c <c@example.com>' : 'z <z@example.com>',\n" + "}, fail_if_not_found = True)");
origin.setAuthor(new Author("a", "a@example.com")).addSimpleChange(0, "change 0");
origin.setAuthor(new Author("b", "b@example.com")).addSimpleChange(1, "change 1");
origin.setAuthor(new Author("c", "c@example.com")).addSimpleChange(2, "change 2");
origin.setAuthor(new Author("Not found", "d@example.com")).addSimpleChange(3, "change 3");
destination.processed.clear();
ValidationException e = assertThrows(ValidationException.class, () -> wf.run(workdir, ImmutableList.of()));
assertThat(e).hasMessageThat().contains("Cannot find a mapping for author 'Not found <d@example.com>'");
assertThat(destination.processed.get(0).getAuthor().toString()).isEqualTo("x <x@example.com>");
assertThat(destination.processed.get(1).getAuthor().toString()).isEqualTo("y <y@example.com>");
assertThat(destination.processed.get(2).getAuthor().toString()).isEqualTo("z <z@example.com>");
}
use of com.google.copybara.authoring.Author in project copybara by google.
the class MetadataModuleTest method testsSaveAuthor.
@Test
public void testsSaveAuthor() throws Exception {
Workflow<?, ?> wf = createWorkflow(WorkflowMode.ITERATIVE, "metadata.save_author()");
origin.setAuthor(new Author("keep me", "keep@me.com")).addSimpleChange(0, "A change");
wf.run(workdir, ImmutableList.of());
ProcessedChange change = Iterables.getLast(destination.processed);
assertThat(change.getChangesSummary()).contains("ORIGINAL_AUTHOR=keep me <keep@me.com>");
}
Aggregations