anticoders / gagarin

Another testing framework for your meteor apps.
gagarin.meteor.com
MIT License
150 stars 21 forks source link

access the test database contents during/after tests #112

Open welelay opened 9 years ago

welelay commented 9 years ago

I'd like to be able to access the database post-mortem. At best, follow collections in genghisapp during the tests.

problems:

  1. databases dropped after tests
  2. private mongod locks the db during tests

For 1. Currently (released version) databases are not dropped at the end, so I can run mongod --dbpath .gagarin/local/db after tests and see them in genghisapp. This is not the case with master eef7c799e2dd34e1a6c0fbb9e452e694b21f4405, where dbs are dropped even when interrupting with Ctrl-C (#85 indicates the contrary??).

For 2. I'd like gagarin to not spawn a mongod but connect to a running one.

I tried to do

describe('Test connect to db', function() {
    var db = mongo({
        mongoUrl: 'mongodb://localhost:27017/testeric'
    });

    it('should create a collection', function() {
        var collection = db.collection('simple_methods');
    });
})

just to connect to an existing mongod. But the options are expunged in context.mongo (lib/mocha/interface.js).

In the end I'd like to run MONGO_URL=mongodb://localhost:27017/testeric gagarin and it uses the existing mongod. I think it's related to #32.

apendua commented 9 years ago

@welelay Thank you for this insight. I am currently in the process of cleaning up mongoDB interface and I will definitely take your suggestions into account.

welelay commented 9 years ago

@apendua cool ! While you're at it, can you add deeper forwarding of the options (see pull request) ? Thanks

apendua commented 9 years ago

@welelay Yeah, I've seen the PR. Lemme think a little and I will probably give it a try.