From b10436ff1cf22bdda44a78e003f295f71712f18a Mon Sep 17 00:00:00 2001 From: smarcet Date: Mon, 12 Oct 2026 15:56:08 -0300 Subject: [PATCH] fix(tests): fake the s3 disk in csv import tests #630 bound the ticket, event, registration company and selection plan member imports to the s3 storage strategies, but the tests still faked and wrote to the swift disk. In CI the real s3 disk has no region, so the imports threw "Missing required client configuration options" and SummitServiceTest, SummitSelectionPlanServiceTest and the oauth2 ingest tests failed. Fake and write to the s3 disk instead, and fake it in the two ticket ingest tests that previously relied on the real disk. --- tests/SummitSelectionPlanServiceTest.php | 12 ++++++------ tests/SummitServiceTest.php | 16 ++++++++-------- .../OAuth2SummitRegistrationCompaniesApiTest.php | 2 +- tests/oauth2/OAuth2SummitTicketsApiTest.php | 5 +++++ 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/tests/SummitSelectionPlanServiceTest.php b/tests/SummitSelectionPlanServiceTest.php index 87b78a44d2..2a623647da 100644 --- a/tests/SummitSelectionPlanServiceTest.php +++ b/tests/SummitSelectionPlanServiceTest.php @@ -47,7 +47,7 @@ protected function tearDown(): void */ public function testProcessAllowedMemberDataImportsAllRowsWhenEveryRowIsValid() { - Storage::fake('swift'); + Storage::fake('s3'); $service = App::make(ISummitSelectionPlanService::class); $summit_id = self::$summit->getId(); @@ -65,7 +65,7 @@ public function testProcessAllowedMemberDataImportsAllRowsWhenEveryRowIsValid() $filename = 'allowed_members_all_valid.csv'; $path = "tmp/selection_plans_allowed_members/{$filename}"; - Storage::disk('swift')->put($path, $csv_content); + Storage::disk('s3')->put($path, $csv_content); $service->processAllowedMemberData($summit_id, $selection_plan_id, $filename); @@ -80,7 +80,7 @@ public function testProcessAllowedMemberDataImportsAllRowsWhenEveryRowIsValid() ); } $this->assertFalse( - Storage::disk('swift')->exists($path), + Storage::disk('s3')->exists($path), 'A fully-processed import must delete its source file' ); } @@ -94,7 +94,7 @@ public function testProcessAllowedMemberDataImportsAllRowsWhenEveryRowIsValid() */ public function testProcessAllowedMemberDataImportsOnlyValidRowsWhenMostRowsAreSkipped() { - Storage::fake('swift'); + Storage::fake('s3'); $service = App::make(ISummitSelectionPlanService::class); $summit_id = self::$summit->getId(); @@ -132,7 +132,7 @@ public function testProcessAllowedMemberDataImportsOnlyValidRowsWhenMostRowsAreS $filename = 'allowed_members_mixed.csv'; $path = "tmp/selection_plans_allowed_members/{$filename}"; - Storage::disk('swift')->put($path, $csv_content); + Storage::disk('s3')->put($path, $csv_content); // must not throw: non-importable rows are skipped by the row guards $service->processAllowedMemberData($summit_id, $selection_plan_id, $filename); @@ -153,7 +153,7 @@ public function testProcessAllowedMemberDataImportsOnlyValidRowsWhenMostRowsAreS 'Only the 5 new emails should have been added - no duplicates, no empties' ); $this->assertFalse( - Storage::disk('swift')->exists($path), + Storage::disk('s3')->exists($path), 'Skipped rows are not failures - the file must still be deleted' ); } diff --git a/tests/SummitServiceTest.php b/tests/SummitServiceTest.php index c989042abe..f2c2fd1b37 100644 --- a/tests/SummitServiceTest.php +++ b/tests/SummitServiceTest.php @@ -91,7 +91,7 @@ private function nonConflictingEventWindow(): array */ public function testProcessRegistrationCompaniesDataSkipsFailingRowButProcessesLaterRows() { - Storage::fake('swift'); + Storage::fake('s3'); $service = App::make(ISummitService::class); $summit_id = self::$summit->getId(); @@ -110,7 +110,7 @@ public function testProcessRegistrationCompaniesDataSkipsFailingRowButProcessesL CSV; $filename = 'registration_companies_isolation_test.csv'; - Storage::disk('swift')->put("tmp/registration_companies_import/{$filename}", $csv_content); + Storage::disk('s3')->put("tmp/registration_companies_import/{$filename}", $csv_content); // processRegistrationCompaniesData() catches each row's transaction failure // locally, so it returns normally even though the first row fails. @@ -243,7 +243,7 @@ public function testUpdateAndPublishEventsRollsBackAlreadyCommittedFirstItemWhen */ public function testProcessEventDataImportsAllRowsWhenEveryRowIsValid() { - Storage::fake('swift'); + Storage::fake('s3'); $service = App::make(ISummitService::class); $summit_id = self::$summit->getId(); @@ -262,7 +262,7 @@ public function testProcessEventDataImportsAllRowsWhenEveryRowIsValid() $filename = 'events_all_valid.csv'; $path = "tmp/events_imports/{$filename}"; - Storage::disk('swift')->put($path, $csv_content); + Storage::disk('s3')->put($path, $csv_content); $service->processEventData($summit_id, $filename, false); @@ -274,7 +274,7 @@ public function testProcessEventDataImportsAllRowsWhenEveryRowIsValid() $this->assertEquals($summit_id, $event->getSummitId()); } $this->assertFalse( - Storage::disk('swift')->exists($path), + Storage::disk('s3')->exists($path), 'A fully-processed import must delete its source file' ); } @@ -288,7 +288,7 @@ public function testProcessEventDataImportsAllRowsWhenEveryRowIsValid() */ public function testProcessEventDataImportsOnlyValidRowsWhenMostRowsFail() { - Storage::fake('swift'); + Storage::fake('s3'); $service = App::make(ISummitService::class); $summit_id = self::$summit->getId(); @@ -316,7 +316,7 @@ public function testProcessEventDataImportsOnlyValidRowsWhenMostRowsFail() $filename = 'events_mixed.csv'; $path = "tmp/events_imports/{$filename}"; - Storage::disk('swift')->put($path, $csv_content); + Storage::disk('s3')->put($path, $csv_content); // must not throw: failing rows are logged and skipped $service->processEventData($summit_id, $filename, false); @@ -338,7 +338,7 @@ public function testProcessEventDataImportsOnlyValidRowsWhenMostRowsFail() ); } $this->assertFalse( - Storage::disk('swift')->exists($path), + Storage::disk('s3')->exists($path), 'Known per-row failures must not block the source file deletion' ); } diff --git a/tests/oauth2/OAuth2SummitRegistrationCompaniesApiTest.php b/tests/oauth2/OAuth2SummitRegistrationCompaniesApiTest.php index a4760b9b8f..65ff6438de 100644 --- a/tests/oauth2/OAuth2SummitRegistrationCompaniesApiTest.php +++ b/tests/oauth2/OAuth2SummitRegistrationCompaniesApiTest.php @@ -132,7 +132,7 @@ public function testRemoveCompanyFromSummit() public function testIngestRegistrationCompanies() { - Storage::fake('swift'); + Storage::fake('s3'); Queue::fake(); $csv_content = <<