How to populate a test database in velocity/cucumber


#1

I’ve started using the standard recommended xolvio:cucumber and velocity:html-reporter.

I want to test against a fairly big test database. I have a dump of the data created by mongodump, and I usually run a script that does mongorestore to load it into a reset local meteor database.

I can imagine having a hook in cucumber’s this.Before that tells the server to import the .json files by reading the text files, parsing them, etc. by hand. This feels ugly. Is there some clean canonical way to import this data into the mirror database?


#2

You can define a Meteor method in a fixtures package that is debugOnly: true (Example: https://github.com/xolvio/Letterpress/tree/master/app/packages/fixtures). To load the data into the DB you can still use mongodump. Just use child_process.exec to execute it from the Meteor method.
The package https://atmospherejs.com/xolvio/cleaner can reset your database in case mongodump doesn’t handle this.


#3

Thanks Sanjo.

For future readers, one key piece of info for your implementation is that the velocity mirrors all point at a local mongodb database meteor-cucumber

So in my case, I restore via

mongorestore -h 127.0.0.1:3001 -d meteor-cucumber ./testDB