Search in sources :

Example 1 with NotADestinationFileException

use of com.google.copybara.exception.NotADestinationFileException in project copybara by google.

the class WorkflowTest method errorWritingMultipleFilesThatDoNotMatchDestinationFiles.

@Test
public void errorWritingMultipleFilesThatDoNotMatchDestinationFiles() throws Exception {
    // 'foo42' is like a file that is expected to be in the destination but not
    // originating from the origin repo (e.g. a metadata file specific to one repo type).
    // In this example, though, the file is copied from the origin, hence an error.
    destinationFiles = "glob(['foo*'], exclude = ['foo42'])";
    transformations = ImmutableList.of();
    Path originDir = Files.createTempDirectory("change1");
    Files.write(originDir.resolve("bar"), new byte[] {});
    Files.write(originDir.resolve("foo_included"), new byte[] {});
    Files.write(originDir.resolve("foo42"), new byte[] {});
    origin.addChange(/*timestamp=*/
    42, originDir, "change1", /*matchesGlob=*/
    true);
    Workflow<?, ?> workflow = skylarkWorkflow("default", SQUASH);
    NotADestinationFileException thrown = assertThrows(NotADestinationFileException.class, () -> workflow.run(workdir, ImmutableList.of(HEAD)));
    assertThat(thrown).hasMessageThat().contains("[bar, foo42]");
}
Also used : Path(java.nio.file.Path) FileSubjects.assertThatPath(com.google.copybara.testing.FileSubjects.assertThatPath) NotADestinationFileException(com.google.copybara.exception.NotADestinationFileException) Test(org.junit.Test)

Example 2 with NotADestinationFileException

use of com.google.copybara.exception.NotADestinationFileException in project copybara by google.

the class WorkflowTest method errorWritingFileThatDoesNotMatchDestinationFiles.

@Test
public void errorWritingFileThatDoesNotMatchDestinationFiles() throws Exception {
    destinationFiles = "glob(['foo*'], exclude = ['foo42'])";
    transformations = ImmutableList.of();
    origin.singleFileChange(/*timestamp=*/
    44, "one commit", "bar.txt", "1");
    Workflow<?, ?> workflow = skylarkWorkflow("default", SQUASH);
    NotADestinationFileException thrown = assertThrows(NotADestinationFileException.class, () -> workflow.run(workdir, ImmutableList.of(HEAD)));
    assertThat(thrown).hasMessageThat().contains("[bar.txt]");
}
Also used : NotADestinationFileException(com.google.copybara.exception.NotADestinationFileException) Test(org.junit.Test)

Aggregations

NotADestinationFileException (com.google.copybara.exception.NotADestinationFileException)2 Test (org.junit.Test)2 FileSubjects.assertThatPath (com.google.copybara.testing.FileSubjects.assertThatPath)1 Path (java.nio.file.Path)1