Skip to content

Commit 754e623

Browse files
fix(drive): correct integration test
1 parent 338915a commit 754e623

4 files changed

Lines changed: 28 additions & 4 deletions

File tree

src/application/services/subject_group_service.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,15 @@ mod integration_tests {
563563
let pool = Arc::new(pool);
564564
let repo = Arc::new(SubjectGroupPgRepository::new(pool.clone()));
565565
let user_storage = Arc::new(UserPgRepository::new(pool.clone()));
566-
SubjectGroupService::new(repo, pool, user_storage)
566+
// The engine is wired so `add_member` / `remove_member` can invalidate
567+
// their stale `user_groups_cache` entries (the production path).
568+
// A stub engine is enough — these tests never trigger an authz SQL
569+
// round-trip, only the in-memory cache invalidation calls. The stub's
570+
// lazy invalid pool would panic if reached, surfacing any drift if a
571+
// future test starts exercising real authz lookups.
572+
let engine =
573+
Arc::new(crate::infrastructure::services::pg_acl_engine::PgAclEngine::new_stub());
574+
SubjectGroupService::new(repo, pool, user_storage, engine)
567575
}
568576

569577
async fn first_admin(pool: &sqlx::PgPool) -> Uuid {

src/infrastructure/repositories/pg/file_blob_read_repository.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,11 @@ impl FileBlobReadRepository {
345345
}
346346

347347
/// Creates a stub instance for testing — never hits PG.
348-
#[cfg(test)]
348+
/// Available in both standard unit-test (`cfg(test)`) and integration
349+
/// (`cfg(integration_tests)`) builds; `PgAclEngine::new_stub` chains
350+
/// into this stub and is needed from the integration-test module of
351+
/// `subject_group_service`.
352+
#[cfg(any(test, integration_tests))]
349353
pub fn new_stub() -> Self {
350354
use crate::infrastructure::services::dedup_service::DedupService;
351355
Self {

src/infrastructure/services/dedup_service.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,13 @@ impl DedupService {
291291
}
292292

293293
/// Creates a stub instance for testing — never hits PG or the filesystem.
294-
#[cfg(any(test, feature = "integration_tests"))]
294+
///
295+
/// Gated for both build modes integration tests are reachable from:
296+
/// the raw `cfg(integration_tests)` flag used by CI / justfile
297+
/// (`RUSTFLAGS='--cfg integration_tests'`) and the
298+
/// `feature = "integration_tests"` form for callers that flip the
299+
/// cargo feature instead. Standard `cfg(test)` keeps unit-test use.
300+
#[cfg(any(test, integration_tests, feature = "integration_tests"))]
295301
pub fn new_stub() -> Self {
296302
use crate::infrastructure::services::local_blob_backend::LocalBlobBackend;
297303
let stub_pool = Arc::new(

src/infrastructure/services/pg_acl_engine.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,13 @@ impl PgAclEngine {
201201
/// without a real PostgreSQL pool. Connecting to the lazy pool will
202202
/// fail at runtime — only safe in tests that exercise types, not actual
203203
/// authz queries.
204-
#[cfg(test)]
204+
///
205+
/// Visible under both `cfg(test)` (the standard unit-test build) and
206+
/// `cfg(integration_tests)` (the gated-by-RUSTFLAGS integration
207+
/// build). The `SubjectGroupService` integration tests construct the
208+
/// service with a stub engine, since they only exercise the engine's
209+
/// in-memory cache invalidation calls — never its SQL paths.
210+
#[cfg(any(test, integration_tests))]
205211
pub fn new_stub() -> Self {
206212
let pool = sqlx::pool::PoolOptions::<sqlx::Postgres>::new()
207213
.max_connections(1)

0 commit comments

Comments
 (0)