Search in sources :

Example 1 with GerritProcessPushOutput

use of com.google.copybara.git.GerritDestination.GerritProcessPushOutput in project copybara by google.

the class GerritDestinationTest method testProcessPushOutput_new.

@Test
public void testProcessPushOutput_new() throws Exception {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    GerritProcessPushOutput process = new GerritProcessPushOutput(LogConsole.readWriteConsole(System.in, new PrintStream(out), /*verbose=*/
    false));
    fakeOneCommitInDestination();
    ImmutableList<DestinationEffect> result = process.process(GERRIT_RESPONSE, /*newReview*/
    true, repo(), Changes.EMPTY.getCurrent());
    assertThat(out.toString()).contains("INFO: New Gerrit review created at https://some.url.google.com/1234");
    assertThat(result).hasSize(2);
    assertThat(result.get(0).getErrors()).isEmpty();
    assertThat(result.get(0).getType()).isEqualTo(Type.CREATED);
    assertThat(result.get(0).getDestinationRef().getType()).isEqualTo("commit");
    assertThat(result.get(0).getDestinationRef().getId()).matches("[0-9a-f]{40}");
    assertThat(result.get(1).getSummary()).contains("New Gerrit review created at https://some.url.google.com/1234");
    assertThat(result.get(1).getType()).isEqualTo(Type.CREATED);
    assertThat(result.get(1).getDestinationRef().getId()).isEqualTo("1234");
    assertThat(result.get(1).getDestinationRef().getType()).isEqualTo("gerrit_review");
    assertThat(result.get(1).getDestinationRef().getUrl()).isEqualTo("https://some.url.google.com/1234");
}
Also used : PrintStream(java.io.PrintStream) DestinationEffect(com.google.copybara.DestinationEffect) ByteArrayOutputStream(java.io.ByteArrayOutputStream) GerritProcessPushOutput(com.google.copybara.git.GerritDestination.GerritProcessPushOutput) Test(org.junit.Test)

Example 2 with GerritProcessPushOutput

use of com.google.copybara.git.GerritDestination.GerritProcessPushOutput in project copybara by google.

the class GerritDestinationTest method testProcessPushOutput_existing.

@Test
public void testProcessPushOutput_existing() throws Exception {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    GerritProcessPushOutput process = new GerritProcessPushOutput(LogConsole.readWriteConsole(System.in, new PrintStream(out), /*verbose=*/
    false));
    fakeOneCommitInDestination();
    ImmutableList<DestinationEffect> result = process.process(GERRIT_RESPONSE, /*newReview*/
    false, repo(), Changes.EMPTY.getCurrent());
    assertThat(out.toString()).contains("INFO: Updated existing Gerrit review at https://some.url.google.com/1234");
    assertThat(result).hasSize(2);
    assertThat(result.get(0).getErrors()).isEmpty();
    assertThat(result.get(0).getType()).isEqualTo(Type.CREATED);
    assertThat(result.get(0).getDestinationRef().getType()).isEqualTo("commit");
    assertThat(result.get(0).getDestinationRef().getId()).matches("[0-9a-f]{40}");
    assertThat(result.get(1).getSummary()).contains("Updated existing Gerrit review at https://some.url.google.com/1234");
    assertThat(result.get(1).getType()).isEqualTo(Type.UPDATED);
    assertThat(result.get(1).getDestinationRef().getId()).isEqualTo("1234");
    assertThat(result.get(1).getDestinationRef().getType()).isEqualTo("gerrit_review");
    assertThat(result.get(1).getDestinationRef().getUrl()).isEqualTo("https://some.url.google.com/1234");
}
Also used : PrintStream(java.io.PrintStream) DestinationEffect(com.google.copybara.DestinationEffect) ByteArrayOutputStream(java.io.ByteArrayOutputStream) GerritProcessPushOutput(com.google.copybara.git.GerritDestination.GerritProcessPushOutput) Test(org.junit.Test)

Aggregations

DestinationEffect (com.google.copybara.DestinationEffect)2 GerritProcessPushOutput (com.google.copybara.git.GerritDestination.GerritProcessPushOutput)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 PrintStream (java.io.PrintStream)2 Test (org.junit.Test)2