Skip to content

Avoid using hardcoded document paths which could cause conflicts when tests are running concurrently (e.g. on Travis). #250

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 2 commits into from
Oct 20, 2017

Conversation

mikelehen
Copy link
Contributor

For context: I had a failure this morning that I think may have been caused by this

… tests are running concurrently (e.g. on Travis).
return withTestDb(persistence, db => {
return db.doc('rooms/Eros').set({
desc: 'Stuff related to Eros project...',
return withTestDoc(persistence, docRef => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably not worth the effort, but it would be niceish if we picked either docRef or doc and not both :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. If we did that I'd say we should do it in a separate PR... but I don't think it's worth the effort. :-)

expect(querySnap.size).to.equal(0);
expect(querySnap.docs.length).to.equal(0);
})
.then(() => unlisten(), () => unlisten());
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this swallow test failures?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorta'. I think expect() will store any failures out-of-band and the test will still fail, but if we accidentally threw an exception then it would probably get swallowed. I removed the error handling case; if the test fails I don't care if it cleans up after itself. :-)

[to be clear, I didn't touch this code originally; it just got reformatted and github can't diff whitespace]

@@ -510,13 +510,12 @@ apiDescribe('Database transactions', persistence => {
});

asyncIt('cannot have a get without mutations', () => {
return integrationHelpers.withTestDb(persistence, db => {
const docRef = db.doc('foo/bar');
Copy link
Contributor

Choose a reason for hiding this comment

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

In this case, I would just leave the old code (so you don't have to to docRef.firestore later). You can still use .doc() to ensure randomness.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay. Not sure it makes much difference, but switched back in the spirit of not changing things unnecessarily. :-)

@mikelehen mikelehen merged commit a8181f4 into master Oct 20, 2017
@mikelehen mikelehen deleted the firestore-test-collisions branch October 20, 2017 22:31
@firebase firebase locked and limited conversation to collaborators Oct 25, 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.

4 participants