Search in sources :

Example 11 with ProcessedChange

use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.

the class WorkflowTest method changeRequest_customRevIdLabel.

@Test
public void changeRequest_customRevIdLabel() throws Exception {
    origin.addSimpleChange(0, "One Change\n\nCUSTOM_REV_ID=42").addSimpleChange(1, "Second Change");
    extraWorkflowFields = ImmutableList.of("experimental_custom_rev_id = \"CUSTOM_REV_ID\"");
    setRevId = false;
    Workflow<?, ?> workflow = changeRequestWorkflow(null);
    workflow.run(workdir, ImmutableList.of("1"));
    ProcessedChange change = destination.processed.get(0);
    assertThat(change.getBaseline()).isEqualTo("42");
    assertThat(change.getAuthor()).isEqualTo(DEFAULT_AUTHOR);
    console().assertThat().onceInLog(MessageType.PROGRESS, ".*Checking that the transformations can be reverted");
}
Also used : ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) Test(org.junit.Test)

Example 12 with ProcessedChange

use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.

the class WorkflowTest method squashReadsLatestAffectedChangeInRoot.

@Test
public void squashReadsLatestAffectedChangeInRoot() throws Exception {
    origin.addSimpleChange(/*timestamp*/
    1);
    transformations = ImmutableList.of();
    Workflow<?, ?> workflow = workflow();
    workflow.run(workdir, ImmutableList.of("HEAD"));
    origin.addSimpleChange(/*timestamp*/
    2);
    DummyRevision expected = origin.resolve("HEAD");
    origin.addChange(/*timestamp*/
    3, Paths.get("not important"), "message", /*matchesGlob=*/
    false);
    options.setForce(false);
    workflow = skylarkWorkflow("default", SQUASH);
    workflow.run(workdir, ImmutableList.of("HEAD"));
    ProcessedChange change = Iterables.getLast(destination.processed);
    assertThat(change.getOriginRef().asString()).isEqualTo(expected.asString());
}
Also used : ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) DummyRevision(com.google.copybara.testing.DummyRevision) Test(org.junit.Test)

Example 13 with ProcessedChange

use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.

the class WorkflowTest method testSquashCustomLabel.

@Test
public void testSquashCustomLabel() throws Exception {
    origin.addSimpleChange(/*timestamp*/
    0);
    origin.addSimpleChange(/*timestamp*/
    1);
    options.workflowOptions.lastRevision = resolveHead();
    origin.addSimpleChange(/*timestamp*/
    2);
    origin.addSimpleChange(/*timestamp*/
    3);
    extraWorkflowFields = ImmutableList.of("experimental_custom_rev_id = \"CUSTOM_REV_ID\"");
    Workflow<?, ?> workflow = skylarkWorkflow("default", SQUASH);
    workflow.run(workdir, ImmutableList.of(HEAD));
    assertThat(destination.processed).hasSize(1);
    ProcessedChange change = Iterables.getOnlyElement(destination.processed);
    assertThat(change.getRevIdLabel()).isEqualTo("CUSTOM_REV_ID");
    assertThat(change.getOriginRef().asString()).isEqualTo("3");
    options.workflowOptions.lastRevision = null;
    workflow = skylarkWorkflow("default", SQUASH);
    assertThat(Iterables.getOnlyElement(workflow.getInfo().migrationReferences()).getLastMigrated().asString()).isEqualTo("3");
    origin.addSimpleChange(/*timestamp*/
    4);
    origin.addSimpleChange(/*timestamp*/
    5);
    workflow.run(workdir, ImmutableList.of(HEAD));
    ProcessedChange last = Iterables.getLast(destination.processed);
    assertThat(last.getOriginChanges()).hasSize(2);
    assertThat(last.getOriginChanges().get(0).getRevision().asString()).isEqualTo("5");
    assertThat(last.getOriginChanges().get(1).getRevision().asString()).isEqualTo("4");
}
Also used : ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) Test(org.junit.Test)

Example 14 with ProcessedChange

use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.

the class GitOriginTest method partialFetch_canFetchRootFile.

@Test
public void partialFetch_canFetchRootFile() throws Exception {
    RecordsProcessCallDestination destination = new RecordsProcessCallDestination();
    options.testingOptions.destination = destination;
    options.setLastRevision(firstCommitRef);
    Files.write(remote.resolve("file.txt"), new byte[0]);
    git("add", "file.txt");
    git("commit", "-m", "message");
    @SuppressWarnings("unchecked") Workflow<GitRevision, Revision> wf = (Workflow<GitRevision, Revision>) skylark.loadConfig("" + "core.workflow(\n" + "    name = 'default',\n" + "    origin = git.origin(\n" + "         url = '" + url + "',\n" + "         include_branch_commit_logs = True,\n" + "         partial_fetch = True,\n" + "    ),\n" + "    origin_files = glob(['directory/**', 'file.txt']),\n" + "    destination = testing.destination(),\n" + "    authoring = authoring.pass_thru('example <example@example.com>'),\n" + ")\n").getMigration("default");
    wf.run(Files.createTempDirectory("foo"), ImmutableList.of("HEAD"));
    List<ProcessedChange> changes = destination.processed;
    assertThat(changes).hasSize(1);
}
Also used : RecordsProcessCallDestination(com.google.copybara.testing.RecordsProcessCallDestination) ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) Revision(com.google.copybara.Revision) Workflow(com.google.copybara.Workflow) Test(org.junit.Test)

Example 15 with ProcessedChange

use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.

the class GitOriginTest method partialFetchAtGitOrigin.

@Test
public void partialFetchAtGitOrigin() throws Exception {
    Files.createDirectories(remote.resolve("include"));
    Files.write(remote.resolve("include/fileA.txt"), new byte[0]);
    git("add", "include/fileA.txt");
    git("commit", "-m", "not include");
    git("checkout", defaultBranch);
    Files.createDirectories(remote.resolve("include"));
    Files.write(remote.resolve("include/mainline-file.txt"), new byte[0]);
    git("add", "include/mainline-file.txt");
    git("commit", "-m", "message_a!");
    options.setForce(true);
    RecordsProcessCallDestination destination = new RecordsProcessCallDestination();
    options.testingOptions.destination = destination;
    options.setLastRevision(firstCommitRef);
    @SuppressWarnings("unchecked") Workflow<GitRevision, Revision> wf = (Workflow<GitRevision, Revision>) skylark.loadConfig("" + "core.workflow(\n" + "    name = 'default',\n" + "    origin = git.origin(\n" + "         url = '" + url + "',\n" + "         include_branch_commit_logs = True,\n" + "         partial_fetch = True,\n" + "    ),\n" + "    origin_files = glob(['include/mainline-file.txt']),\n" + "    destination = testing.destination(),\n" + "    mode = 'ITERATIVE',\n" + "    authoring = authoring.pass_thru('example <example@example.com>'),\n" + ")\n").getMigration("default");
    wf.run(Files.createTempDirectory("foo"), ImmutableList.of("HEAD"));
    List<ProcessedChange> changes = destination.processed;
    assertThat(changes).hasSize(1);
    assertThat(changes.get(0).getChangesSummary()).contains("message_a!");
}
Also used : RecordsProcessCallDestination(com.google.copybara.testing.RecordsProcessCallDestination) ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) Revision(com.google.copybara.Revision) Workflow(com.google.copybara.Workflow) Test(org.junit.Test)

Aggregations

ProcessedChange (com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange)59 Test (org.junit.Test)57 Author (com.google.copybara.authoring.Author)11 Revision (com.google.copybara.Revision)4 Workflow (com.google.copybara.Workflow)4 RecordsProcessCallDestination (com.google.copybara.testing.RecordsProcessCallDestination)4 ValidationException (com.google.copybara.exception.ValidationException)2 DummyRevision (com.google.copybara.testing.DummyRevision)2 TemporalAccessor (java.time.temporal.TemporalAccessor)1 HashSet (java.util.HashSet)1