Publications and Subscriptions testing query

Hi All,

Was wondering how you do testing around publications…

So my understanding is, need 2 tests for any publication.

  1. Test to ensure publication is sending out correct information.
  2. Test to ensure subscription is sending over correct arguments.

How do you do this? Can someone provide some examples for the following scenario’s?

a. Clean publish, but with some role based filter. Like, how do you think about this? Do i create a new collection in the test, and the do the publish, and then check the output? SO If it was a publish of meteor.users, but only those with a role of ‘admin’ or whatever.
b. Publish with some passed variable: (1) Test on the publish, what happens when no variable is send on the subscribe? (2) Test on subscribe sending dodgy information, i.e. something more sophisticated than check.
c. How do you test the output of your find() basically. I keep making mistakes in my find(…args), but it is completely not obvious when i make an error as the collections are pretty similar…

Any resources you could point me in the direction of would also be appreciated. Thanks so much.

Tat

Just to clarify, the problem is that invariably, my collection is returned with some kind of:
return db.collections.find(query, projection);

Fine, but I’m a muppet, so often my query and projections are shite. Hence the need for testing, i.e. is what is coming back what i expected to come back.

This is compounded by the fact that often the publication is reused for different things…

Tat