Skip to content

Adding call to clearPersistence() into AsyncQueue #1740

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

Merged
merged 9 commits into from
May 2, 2019
Merged

Conversation

thebrianchen
Copy link

No description provided.

@wilhuff wilhuff assigned thebrianchen and unassigned wilhuff May 1, 2019
@thebrianchen thebrianchen assigned wilhuff and unassigned thebrianchen May 1, 2019
@wilhuff wilhuff assigned thebrianchen and unassigned wilhuff May 1, 2019
await expect(clearPersistence(firestore)).to.eventually.be.rejectedWith(
'Failed to delete the database.'
);
SimpleDb.delete = oldDelete;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should pull this out of the withTestDoc block so that you can put it in a finally block

const oldDelete = SimpleDb.delete;
try {
  // monkey patch and test
} finally {
  SimpleDb.delete = oldDelete
}

This form is desirable because it prevents a failure in this test from causing unrelated failures in subsequent tests.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with taking the patch out of withTestDoc is that withTestDoc eventually ends up calling withTestDbsSettings, which clears persistence at the end of the the function. Not restoring SimpleDb.delete to its original definition causes those tests to fail when the test is torn down:

 (Persistence=true) Database
    ✗ will reject the promise if clear persistence fails
	Error: the string "Failed to delete the database :(." was thrown, throw an Error :)

HeadlessChrome 74.0.3729 (Mac OS X 10.14.4) (Persistence=true) Database will reject the promise if clear persistence fails FAILED
	Error: the string "Failed to delete the database :(." was thrown, throw an Error :)

What do you think about resetting SimpleDb.delete twice just to be safe?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not do the try/finally inside withTestDoc then?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once again, thank you. 🤦

@thebrianchen thebrianchen assigned wilhuff and unassigned thebrianchen May 2, 2019
@wilhuff wilhuff assigned thebrianchen and unassigned wilhuff May 2, 2019
@thebrianchen thebrianchen assigned wilhuff and unassigned thebrianchen May 2, 2019
Copy link
Contributor

@wilhuff wilhuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks for taking the time to make this right!

@wilhuff wilhuff assigned thebrianchen and unassigned wilhuff May 2, 2019
@thebrianchen thebrianchen merged commit 9f25ab6 into master May 2, 2019
@thebrianchen thebrianchen deleted the bc/persist branch May 2, 2019 21:06
@firebase firebase locked and limited conversation to collaborators Oct 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants