Skip to content

Commit

Permalink
Check if the same change was updated
Browse files Browse the repository at this point in the history
  • Loading branch information
mtughan committed Sep 5, 2024
1 parent 4b63ea9 commit 8bbf1f1
Showing 1 changed file with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ void test1() throws Exception {
@Test
@DisplayName("Good quality freestyle build")
void test2() throws Exception {
testWithGoodQualityCode(this::createFreestyleJob, false);
testWithGoodQualityCode(this::createFreestyleJob, false, null);
}

@Test
@DisplayName("Bad then good quality freestyle build")
void test3() throws Exception {
testWithBadQualityCode(this::createFreestyleJob);
testWithGoodQualityCode(this::createFreestyleJob, true);
GerritChange change = testWithBadQualityCode(this::createFreestyleJob);
testWithGoodQualityCode(this::createFreestyleJob, true, change);
}

@Test
Expand All @@ -123,17 +123,17 @@ void test4() throws Exception {
@Test
@DisplayName("Good quality pipeline build")
void test5() throws Exception {
testWithGoodQualityCode(this::createPipelineJob, false);
testWithGoodQualityCode(this::createPipelineJob, false, null);
}

@Test
@DisplayName("Bad then good quality pipeline build")
void test6() throws Exception {
testWithBadQualityCode(this::createPipelineJob);
testWithGoodQualityCode(this::createFreestyleJob, true);
GerritChange change = testWithBadQualityCode(this::createPipelineJob);
testWithGoodQualityCode(this::createFreestyleJob, true, change);
}

private void testWithBadQualityCode(JobFactory jobFactory) throws Exception {
private GerritChange testWithBadQualityCode(JobFactory jobFactory) throws Exception {
git.addAndCommitFile(
"src/main/java/org/example/Foo.java",
"package org.example; public class Foo { public Foo() {} }");
Expand All @@ -150,9 +150,12 @@ private void testWithBadQualityCode(JobFactory jobFactory) throws Exception {
.map(commentInfo -> commentInfo.message)
.filteredOn(message -> message.contains("S1186"))
.hasSize(1);

return change;
}

private void testWithGoodQualityCode(JobFactory jobFactory, boolean amend) throws Exception {
private void testWithGoodQualityCode(
JobFactory jobFactory, boolean amend, GerritChange previousChange) throws Exception {
git.addAndCommitFile(
"src/main/java/org/example/Foo.java",
"package org.example; public interface Foo {}",
Expand All @@ -167,6 +170,9 @@ private void testWithGoodQualityCode(JobFactory jobFactory, boolean amend) throw
.map(approvalInfo -> approvalInfo.value)
.containsExactly(1);
assertThat(change.listComments()).isEmpty();
if (previousChange != null) {
assertThat(previousChange.changeNumericId()).isEqualTo(change.changeNumericId());
}
}

@SuppressWarnings("rawtypes")
Expand Down

0 comments on commit 8bbf1f1

Please sign in to comment.