[SOLVED] How can I test collection method in a packages


#1

Hi there,

I have a simple package which expose some utility methods which in turn touch some collection docs, i would like to test these methods. But I could not get it pass the client test. Anyone could show me the way?

It’s like, my method will call myCollection.update() (in /lib folder, which will have the default meteor client then server calls). Now i want to test this method in my package. But could not pass through the: Not permitted. Untrusted code may only update documents by ID. [403]

I do have the allow before my test case. :frowning:


#2

Two options.

EDIT: To clarify. I think your test is correct. It’s a problem with your implementation. Read in the docs how it behaves when you expose the Meteor.methods block to the client: http://docs.meteor.com/#/full/methods_header.


#3

Really appreciate the guidance. :smile:

I was thinking about isSimulation call though. But I don really get it why it does not work on package test but it works on the actual app.

I might need to rephrase. my utility methods, are not meteor method. Just public function that in the /lib library in a package. And it has myCollection.update() call.

Anyways, thanks ya. :smile: