mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 22:37:55 -05:00
fix(codebuild): paginate ListReportGroups responses (#6524)
* fix(codebuild): paginate ListReportGroups responses * fix(codebuild): snapshot report group pagination keys * refactor(codebuild): share listing pagination and snapshot project keys
This commit is contained in:
1 parent
3389621dc6
commit
28d934fd8e
5 files changed
+430
-86
No files matched your search
+49
@@ -0,0 +1,49 @@
|
||||
package com.floci.test;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import software.amazon.awssdk.services.codebuild.CodeBuildClient;
|
||||
import software.amazon.awssdk.services.codebuild.model.ListReportGroupsResponse;
|
||||
import software.amazon.awssdk.services.codebuild.model.ReportExportConfigType;
|
||||
import software.amazon.awssdk.services.codebuild.model.ReportGroupSortByType;
|
||||
import software.amazon.awssdk.services.codebuild.model.ReportType;
|
||||
import software.amazon.awssdk.services.codebuild.model.SortOrderType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class CodeBuildReportGroupPaginationTest {
|
||||
|
||||
@Test
|
||||
void paginatorReturnsEveryReportGroupOnce() {
|
||||
String prefix = "sdk-page-" + UUID.randomUUID() + "-";
|
||||
List<String> created = new ArrayList<>();
|
||||
try (CodeBuildClient client = TestFixtures.codeBuildClient()) {
|
||||
try {
|
||||
for (String suffix : List.of("a", "b", "c")) {
|
||||
created.add(client.createReportGroup(request -> request.name(prefix + suffix)
|
||||
.type(ReportType.TEST)
|
||||
.exportConfig(config -> config.exportConfigType(ReportExportConfigType.NO_EXPORT)))
|
||||
.reportGroup().arn());
|
||||
}
|
||||
List<String> seen = new ArrayList<>();
|
||||
int pages = 0;
|
||||
for (ListReportGroupsResponse page : client.listReportGroupsPaginator(request -> request
|
||||
.maxResults(1).sortBy(ReportGroupSortByType.NAME).sortOrder(SortOrderType.ASCENDING))) {
|
||||
assertThat(page.reportGroups()).hasSizeLessThanOrEqualTo(1);
|
||||
seen.addAll(page.reportGroups());
|
||||
assertThat(++pages).as("pagination must end").isLessThan(1000);
|
||||
}
|
||||
assertThat(seen).doesNotHaveDuplicates();
|
||||
assertThat(seen.stream().filter(arn -> arn.contains(prefix)).toList())
|
||||
.containsExactlyElementsOf(created);
|
||||
} finally {
|
||||
for (String arn : created) {
|
||||
client.deleteReportGroup(request -> request.arn(arn));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user