🐛 Support applications that do not use every Google service in the fixtures - #189
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 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: theFirestoreFixturethrew during teardown because the application provides noFirestore, and theSpannerFixturecreated 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
FirestoreFixtureand theSpannerFixtureare 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: theSpannerFixturecreates its temporary database from the factory replacing theDatabaseprovider rather than eagerly during initialization, so no database is created for an application without Spanner, and theFirestoreFixtureclears nothing when its factory was never called.createGoogleFixturescan 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
FirestoreFixtureterminates 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, thePubSubFixturedeletes 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
SpannerFixturenow replaces theDatabaseprovider with a factory, it no longer overrides aDatabasedeclared withuseValue. Applications usingSpannerModuleare unaffected.📋 Check list