From 1a804ae5472cdaa4d9bf1dcb016ac456a9a007b5 Mon Sep 17 00:00:00 2001 From: BingEdward <1042653432@qq.com> Date: Tue, 8 Sep 2026 21:51:49 +0800 Subject: [PATCH] fix(test): tear down the organization DetectiveIntegrationTest creates (#3229) DetectiveIntegrationTest creates an organization on account 000000000000 through the injected OrganizationsService and never deletes it. Organizations state is shared by every @QuarkusTest class in the same Surefire fork, so any class that lands in the same shard and later creates an organization under the default account (OrganizationsIntegrationTest's @Order(1) createOrganization) fails with AlreadyInOrganizationException and every ordered test after it cascades. Delete the organization in @AfterEach, guarded by a flag so the teardown only runs for the test that created one and a single-method run of the class still works. Fixes #3226 --- .../detective/DetectiveIntegrationTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/test/java/io/github/hectorvent/floci/services/detective/DetectiveIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/detective/DetectiveIntegrationTest.java index a54b680dd3..dc7a5b09c7 100644 --- a/src/test/java/io/github/hectorvent/floci/services/detective/DetectiveIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/detective/DetectiveIntegrationTest.java @@ -4,6 +4,7 @@ import io.github.hectorvent.floci.services.organizations.OrganizationsService; import io.github.hectorvent.floci.testing.RestAssuredJsonUtils; import io.quarkus.test.junit.QuarkusTest; import jakarta.inject.Inject; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -19,14 +20,30 @@ class DetectiveIntegrationTest { @Inject OrganizationsService organizationsService; + private boolean createdOrganization; + @BeforeAll static void configureRestAssured() { RestAssuredJsonUtils.configureAwsContentTypes(); } + /** + * Organizations state is shared by every test in the JVM and keyed by the management account, + * so an organization left behind here makes the next class that creates one under + * {@code 000000000000} (e.g. {@code OrganizationsIntegrationTest}) fail with + * AlreadyInOrganizationException. + */ + @AfterEach + void deleteTheOrganizationThisTestCreated() { + if (createdOrganization) { + organizationsService.deleteOrganization("000000000000"); + } + } + @Test void organizationGraphAndMemberLifecycleMatchesAwsContract() { organizationsService.createOrganization("000000000000", "ALL"); + createdOrganization = true; String enableBody = post("/orgs/enableAdminAccount", "{\"AccountId\":\"000000000000\"}") .statusCode(200).extract().asString(); assertTrue(enableBody.isEmpty());