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 18, 2024
1 parent 3f52de2 commit 1e14fc8
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,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 @@ -132,17 +132,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 @@ -159,15 +159,22 @@ 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 {}",
amend);
GerritChange change = git.createGerritChangeForMaster();

if (previousChange != null) {
assertThat(previousChange.changeNumericId()).isEqualTo(change.changeNumericId());
}

triggerAndAssertSuccess(jobFactory.build(change));

ChangeInfo changeDetail = change.getDetail();
Expand Down

0 comments on commit 1e14fc8

Please sign in to comment.