Search in sources :

Example 11 with DummyOrigin

use of com.google.copybara.testing.DummyOrigin in project copybara by google.

the class MetadataModuleTest method testScrubberFailWithNoPublicMsg.

@Test
public void testScrubberFailWithNoPublicMsg() throws Exception {
    origin = new DummyOrigin().setAuthor(ORIGINAL_AUTHOR);
    origin.addSimpleChange(0, "Confidential 1\nPUBLIC: It is a public msg\n Confidential\n");
    options.testingOptions.origin = origin;
    ValidationException e = assertThrows(ValidationException.class, () -> checkScrubber("This\nis\nvery confidential\nbut this is public\nvery public\n", "metadata.scrubber('^(?:\\n|.)*PUBLIC:((?:\\n|.)*)(?:\\n|.)*$', " + "fail_if_no_match = True," + "replacement = '$1')", /*not used*/
    null));
    assertThat(e).hasMessageThat().contains(// 
    "Scrubber regex: '^(?:\n|.)*PUBLIC:((?:\n|.)*)(?:\n|.)*$' didn't match for " + "description: 'This\n" + "is\n" + "very confidential\n" + "but this is public\n" + "very public\n" + "'");
}
Also used : DummyOrigin(com.google.copybara.testing.DummyOrigin) ValidationException(com.google.copybara.exception.ValidationException) NonReversibleValidationException(com.google.copybara.exception.NonReversibleValidationException) Test(org.junit.Test)

Aggregations

DummyOrigin (com.google.copybara.testing.DummyOrigin)11 OptionsBuilder (com.google.copybara.testing.OptionsBuilder)10 SkylarkTestExecutor (com.google.copybara.testing.SkylarkTestExecutor)10 Before (org.junit.Before)10 TestingConsole (com.google.copybara.util.console.testing.TestingConsole)8 ValidationException (com.google.copybara.exception.ValidationException)5 RecordsProcessCallDestination (com.google.copybara.testing.RecordsProcessCallDestination)5 Test (org.junit.Test)5 Truth.assertThat (com.google.common.truth.Truth.assertThat)4 IOException (java.io.IOException)4 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)4 Files (java.nio.file.Files)4 Path (java.nio.file.Path)4 Joiner (com.google.common.base.Joiner)3 ImmutableList (com.google.common.collect.ImmutableList)3 Iterables (com.google.common.collect.Iterables)3 Lists (com.google.common.collect.Lists)3 Truth.assertWithMessage (com.google.common.truth.Truth.assertWithMessage)3 DestinationStatus (com.google.copybara.Destination.DestinationStatus)3 Writer (com.google.copybara.Destination.Writer)3