Skip to content

🐛 Support applications that do not use every Google service in the fixtures - #189

Merged
flovouin merged 4 commits into
mainfrom
fix/tolerant-fixtures
Jul 31, 2026
Merged

🐛 Support applications that do not use every Google service in the fixtures#189
flovouin merged 4 commits into
mainfrom
fix/tolerant-fixtures

Conversation

@flovouin

@flovouin flovouin commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

📝 Description of the PR

The fixtures provided by this package assumed that the application under test uses every Google service they cover. In practice, an application that only relies on Spanner and Pub/Sub (or only on Firestore) could not use createGoogleFixtures: the FirestoreFixture threw during teardown because the application provides no Firestore, and the SpannerFixture created a temporary Spanner database even though the application never uses one. Working around this meant either adding unused modules to the application, or hand-assembling the list of fixtures that the convenience helper is meant to provide.

The FirestoreFixture and the SpannerFixture are now tolerant of applications that do not use the corresponding service. Both rely on the fact that overriding a provider the application does not declare has no effect: the SpannerFixture creates its temporary database from the factory replacing the Database provider rather than eagerly during initialization, so no database is created for an application without Spanner, and the FirestoreFixture clears nothing when its factory was never called. createGoogleFixtures can therefore be used as-is by applications that rely on any subset of the supported services.

Both fixtures also now create a single instance of their resource even when several modules declare the corresponding provider, and the FirestoreFixture terminates its own Firestore instance during teardown rather than relying on a NestJS shutdown hook, so the client is released even when the application failed to start. Finally, the PubSubFixture deletes the temporary topic it created when the corresponding subscription cannot be created, which previously left an orphan topic behind.

One behavior worth noting for applications that do not use the modules of this package to provide their clients: because the SpannerFixture now replaces the Database provider with a factory, it no longer overrides a Database declared with useValue. Applications using SpannerModule are unaffected.

📋 Check list

  • 🧪 Unit tests have been written.
  • 📝 Documentation has been updated.

@flovouin flovouin added the bug Something isn't working label Jul 31, 2026
@flovouin
flovouin merged commit c212c53 into main Jul 31, 2026
2 checks passed
@flovouin
flovouin deleted the fix/tolerant-fixtures branch July 31, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant