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

Using stubbed collections for publication tests #14

Closed
ebbe-brandstrup opened this issue Jan 24, 2017 · 8 comments
Closed

Using stubbed collections for publication tests #14

ebbe-brandstrup opened this issue Jan 24, 2017 · 8 comments

Comments

@ebbe-brandstrup
Copy link

Hi,

I'm trying to use the johanbrook:meteor-publication-collector package for publication tests. I would like to use stubbed collections to have the tests run quicker.

The stacktrace of the error I get is:

Can't publish a cursor from a collection without a name. at [object Object].LocalCollection.Cursor._publishCursor (packages/minimongo.js:265:11) at packages/johanbrook:publication-collector/publication-collector.js:49:20 at Array.map (native) at PublicationCollector.collect (packages/johanbrook:publication-collector/publication-collector.js:44:47)

It seems to me that the error occurs because this package creates an in-memory (minimongo) collection to replace the real collection by creating a new Meteor collection without a name (null).

I am hoping you have some insight to share?

Thanks!

@ebbe-brandstrup
Copy link
Author

Heads up - the closed issue in the johanbrook:meteor-publication-collector package where I mentioned this issue in did not resolve my problem.

@hwillson
Copy link
Owner

Hi @ebbe-brandstrup - thanks for reporting this. Any chance you could put together a small (runnable) repro showing the exact problem? I'll then use that repro to troubleshoot and fix the issue (I'm a bit swamped right now, so providing a runnable repro would definitely help get a fix for this in faster). Also - I love PR's if you're interested in addressing this issue yourself. Thanks again!

@hwillson
Copy link
Owner

I'll close this for now, but if you're able to supply a small, runnable reproduction that demonstrates this, I'll take a look. Thanks!

coagmano added a commit to coagmano/meteor-stub-collections that referenced this issue Mar 23, 2018
Using a stub-collection with johanbrook:meteor-publication-collector
sometimes causes the error

> Error: Can't publish a cursor from a collection without a name.

The simple fix for this is to create a localCollection with the same
name as the real collection. To ensure the collection doesn't connect
to the same database we pass `{ connection: null }` into the options,
instead of a null name to the constructor.
coagmano added a commit to coagmano/meteor-stub-collections that referenced this issue Mar 23, 2018
Using a stub-collection with johanbrook:meteor-publication-collector
sometimes causes the error

> Error: Can't publish a cursor from a collection without a name.

The simple fix for this is to create a localCollection with a name. To
ensure that the stubbed collection doesn't connect to an existing local
collection that was stubbed previously, we randomise the name.
@coagmano
Copy link
Contributor

I've just run into this issue as well. I was unable to make a simple reproduction, but was able to make a fix.

I've added a PR with that fix in #27

hwillson added a commit that referenced this issue Mar 23, 2018
Fix #14 - Using stubbed collections for publication tests
hwillson added a commit that referenced this issue Mar 23, 2018
@hwillson
Copy link
Owner

Thanks @coagmano - I've merged #27 and published hwillson:stub-collections version 1.0.7. Let me know if you notice any issues. Thanks again!

@coagmano
Copy link
Contributor

just realised that this is more likely to break tests that didn't have this issue before because the collections object returned from PublicationCollector will have the randomised names, where previously folks could just reference the original collection's name.

Working on a better solution that should also fix #24

coagmano added a commit to coagmano/meteor-stub-collections that referenced this issue Mar 26, 2018
@coagmano
Copy link
Contributor

Okay opened a new PR with the changes. Sorry for the mixup!

hwillson added a commit that referenced this issue Mar 26, 2018
@hwillson
Copy link
Owner

No problem @coagmano - thanks for the fix. Published as 1.0.8.

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

No branches or pull requests

3 participants