Mocking Transloadit in Unit Tests

Archived from the Transloadit support forum. Originally posted on September 23, 2011; details may be outdated, see our docs for current behavior. Original thread

Hey guys–

This is just a wish list item. It would be nice if you could provide a testing feature on your API wherein one could submit assemblies and get a normal response, but if we include a “test: true” parameter or something not actually process the assembly. That way in unit tests which actually make calls to the Transloadit API we’d not be worried about the eventual response or the fact that we’re in a local dev environment or something.

Of course, you guys may have some better suggestions on writing unit tests when dealing with APIs like yours, and I’d definitely be willing to hear out anything you have to say.

Thanks!

Hey icdev,

what kind of response would the API give in this case? That depends on the parameters and thus kind of defeats the purpose of mocking. One advantage of mocking is that you as the unittester specify how the mocked object responds.
Sending requests to the API out of mocked objects does not make sense to me as TL is the big bottleneck in your code there (much like the DB is in other cases) that you want to mock.

Does this make sense or am I missing something?

Maybe you want to show some code?

Kind regards,
Tim

Closing this for now. Let us know if you need further help here.