carbon-io / carbond

MIT License
2 stars 5 forks source link

Discussion: Test setup and doStart #233

Closed tfogo closed 6 years ago

tfogo commented 6 years ago

Bumped into something a bit awkward.

I'm setting up collection indexes in Service.doStart. Now when I'm testing, I want to drop the database in setup. In order to have access to the database to drop it, I have to first setup the service. So I get something like this:

setup: function() {
  carbon.carbond.test.ServiceTest.prototype.setup.call(this)

  this.service.db.command({dropDatabase: 1})
  this.service.doStart() // create indexes
}

Seems a bit messy since doStart is being called twice.

Is there a better way to do this? Should I be creating indexes somewhere outside of doStart?

tfogo commented 6 years ago

Note: Spoke to the rest of the team and they said indexes should be built in a script separate from the application. That way you don't accidentally start to build indexes and tank your DB. So no building indexes in doStart.