Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring unit tests to reduce dependency on credentials #431

Merged
merged 6 commits into from
Jan 22, 2019

Conversation

hiranya911
Copy link
Contributor

I want to implement some changes to our credentials, but every time I touch that code a large number of unit tests break. This is because many of our unit tests are tightly coupled with the credentials. A lot of the tests emulate the behavior of credentials by mocking the HTTP call to token servers, and if the credentials change how they talk to the servers even slightly, all the dependent tests break.

This PR reduces this level of coupling by implementing the following changes:

  1. Service-level unit tests (auth, fcm etc.) no longer mock the HTTP call to token servers. Instead, they stub the FirebaseApp.Internals.getToken() method.
  2. FirebaseApp and FirebaseNamespace unit tests stub the getAccessToken() method on the credential classes.
  3. Only the Credential unit tests are allowed to mock the token server HTTP calls. To this end the utils.mockFetchAccessTokenRequests() method has been removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants