jeudi 29 janvier 2015

MongoDB / Mongoose Unit Testing

I'm writing a npm package to import GIS data into MongoDB via mongoose. I've written unit tests using mocha to test the data transformations that happen BEFORE the mongoose model is saved.


However, I'd like to be sure that all the mongoose data got saved correctly to the database (including any updates that needed to occur). How should I do this?


I'm thinking the correct way to go would be to create a test collection, insert all the records, ensure that it looks the way I expect it to look, and drop the collection. Is this the best practice? Does anyone have a code sample or a model npm package / library I should be modelling mine after?


Aucun commentaire:

Enregistrer un commentaire