#db loaded.
db.on('load', function(count) {
done(null);
});
#init with git hook payload.
var payload = SAMPLE_GIT_PAYLOAD;
var nextPort = db.get('nextPort');
var repo = new Repo(payload);
repo.should.be.an['instanceof'](Repo);
repo.branch.should.equal(payload.ref.split('/')[2]);
repo.port.should.equal(nextPort);
// ensure that the nextPort was incremented
db.get('nextPort').should.equal(++nextPort);
#buildRoutes with a default branch (staging).
var repo = new Repo(SAMPLE_GIT_PAYLOAD);
repo.branch = 'staging';
repo.buildRoutes();
var localRoute = '127.0.0.1:' + repo.port;
var mock_routes = {
'soapbox-stg.localhost': localRoute,
'soapbox-staging.localhost': localRoute
};
var routes = repo.routes;
routes.should.deep.equal(mock_routes);
#buildRoutes with custom branch and NO defined domain.
var repo = new Repo(SAMPLE_GIT_PAYLOAD);
repo.branch = 'custom-branch';
repo.buildRoutes();
var localRoute = '127.0.0.1:' + repo.port;
var publicRoute = repo.name + '-' + repo.branch + '.' + config.hostname;
var mock_routes = {};
mock_routes[publicRoute] = localRoute;
repo.routes.should.deep.equal(mock_routes);
#buildRoutes with custom branch and a defined domain.
var repo = new Repo(SAMPLE_GIT_PAYLOAD);
repo.pkgDotJSON = {domain: 'test.com'};
repo.branch = 'custom-branch';
repo.buildRoutes();
var localRoute = '127.0.0.1:' + repo.port;
var publicRoute = repo.branch + '.' + repo.pkgDotJSON.domain;
var mock_routes = {};
mock_routes[publicRoute] = localRoute;
repo.routes.should.deep.equal(mock_routes);
#start.
var repo = new Repo(SAMPLE_API_PAYLOAD);
repo.start(done);
#start without repo (should fail).
var repo = new Repo({githubId: 'distracteddev/deps'});
repo.start(function(err) {
//console.log(err);
should.exist(err);
done(null);
});