Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Commit

Permalink
Merge pull request #82 from npm/ceej/update-lab
Browse files Browse the repository at this point in the history
Updated lab to the latest version
  • Loading branch information
bcoe committed Sep 29, 2014
2 parents 587373d + 4b454a0 commit 386cb63
Show file tree
Hide file tree
Showing 10 changed files with 247 additions and 227 deletions.
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -5,7 +5,7 @@
"main": "./lib/index.js",
"bin": "./bin/ndm.js",
"scripts": {
"test": "lab -c --timeout=8000"
"test": "lab -c --timeout 8000"
},
"author": "Ben Coe <ben@npmjs.com>",
"license": "ISC",
Expand All @@ -24,7 +24,7 @@
"yargs": "^1.3.1"
},
"devDependencies": {
"lab": "^3.2.1",
"lab": "~4.5.1",
"mocha": "^1.20.0"
},
"repository": {
Expand Down
12 changes: 7 additions & 5 deletions test/cli-self-install.js
@@ -1,22 +1,24 @@
require('../lib/config')({headless: true}); // turn off output in tests.

var Lab = require('lab'),
path = require('path'),
_ = require('lodash');
var lab = require('lab'),
Lab = exports.lab = lab.script(),
expect = lab.expect,
path = require('path'),
_ = require('lodash');

Lab.experiment('cli-self-install', function() {
Lab.experiment('init', function() {
Lab.it('should infer module name based on package.json', function(done) {
var ndm = require('../lib')('ndm-test');
Lab.expect(ndm.filter).to.eql('ndm-test');
expect(ndm.filter).to.eql('ndm-test');
done();
});

Lab.it('should allow api opts to be overridden', function(done) {
var ndm = require('../lib')('ndm-test', {
logsDirectory: '/foo/logs'
});
Lab.expect(ndm.logsDirectory).to.eql('/foo/logs');
expect(ndm.logsDirectory).to.eql('/foo/logs');
done();
});
});
Expand Down
46 changes: 24 additions & 22 deletions test/cli-test.js
@@ -1,6 +1,8 @@
require('../lib/config')({headless: true}); // turn off output in tests.

var Lab = require('lab'),
var lab = require('lab'),
Lab = exports.lab = lab.script(),
expect = lab.expect,
Cli = require('../lib/cli'),
_ = require('lodash');

Expand All @@ -16,8 +18,8 @@ Lab.experiment('cli', function() {

var config = require('../lib/config')();

Lab.expect(config.sudo).to.eql(false);
Lab.expect(config.globalPackage).to.eql(true);
expect(config.sudo).to.eql(false);
expect(config.globalPackage).to.eql(true);

done();
});
Expand All @@ -35,7 +37,7 @@ Lab.experiment('cli', function() {

cli.updateConfigWithNpmconf(npmconf);
var config = require('../lib/config')();
Lab.expect(config.modulePrefix).to.eql('./test/fixtures');
expect(config.modulePrefix).to.eql('./test/fixtures');

done();
})
Expand All @@ -50,13 +52,13 @@ Lab.experiment('cli', function() {
var help = cli.yargs.help();

// generations option.
Lab.expect(help).to.match(/-u/);
expect(help).to.match(/-u/);
// generates alias.
Lab.expect(help).to.match(/-sudo/);
expect(help).to.match(/-sudo/);
// generates description.
Lab.expect(help).to.match(/where does the node executable reside/)
expect(help).to.match(/where does the node executable reside/)
// generates defaults.
Lab.expect(help).to.match(/default: .*service\.json/);
expect(help).to.match(/default: .*service\.json/);

done();
});
Expand All @@ -68,7 +70,7 @@ Lab.experiment('cli', function() {

var help = cli.yargs.help();

Lab.expect(help).to.match(/ndm generate/);
expect(help).to.match(/ndm generate/);

done();
});
Expand All @@ -80,7 +82,7 @@ Lab.experiment('cli', function() {
yargs: require('yargs')([]),
logger: {
log: function(str) {
Lab.expect(str).to.match(/Usage:/);
expect(str).to.match(/Usage:/);
done();
}
}
Expand All @@ -94,7 +96,7 @@ Lab.experiment('cli', function() {
yargs: require('yargs')(['generate', '--help']),
logger: {
log: function(str) {
Lab.expect(str).to.match(/Usage:/);
expect(str).to.match(/Usage:/);
done();
}
}
Expand All @@ -109,7 +111,7 @@ Lab.experiment('cli', function() {
logger: {
error: function(str) {},
log: function(str) {
Lab.expect(str).to.match(/Usage:/);
expect(str).to.match(/Usage:/);
done();
}
}
Expand All @@ -125,7 +127,7 @@ Lab.experiment('cli', function() {
var cli = Cli({
yargs: require('yargs')(['generate']),
generate: function(serviceName) {
Lab.expect(serviceName).to.be.undefined;
expect(serviceName).to.be.undefined;
done();
}
});
Expand All @@ -137,7 +139,7 @@ Lab.experiment('cli', function() {
var cli = Cli({
yargs: require('yargs')(['start', 'foobar']),
start: function(serviceName) {
Lab.expect(serviceName).to.eql('foobar');
expect(serviceName).to.eql('foobar');
done();
}
});
Expand All @@ -153,13 +155,13 @@ Lab.experiment('cli', function() {
{
name: 'service1',
runCommand: function(command) {
Lab.expect(command).to.eql('start');
expect(command).to.eql('start');
}
},
{
name: 'service2',
runCommand: function(command) {
Lab.expect(command).to.eql('start');
expect(command).to.eql('start');
done();
}
}
Expand All @@ -186,7 +188,7 @@ Lab.experiment('cli', function() {
{
name: 'service2',
runCommand: function(command) {
Lab.expect(command).to.eql('start');
expect(command).to.eql('start');
done();
}
}
Expand All @@ -212,14 +214,14 @@ Lab.experiment('cli', function() {
name: 'service1',
hasScript: function() { return true; },
runScript: function(command) {
Lab.expect(command).to.eql('foo-script');
expect(command).to.eql('foo-script');
}
},
{
name: 'service2',
hasScript: function() { return true; },
runScript: function(command) {
Lab.expect(command).to.eql('foo-script');
expect(command).to.eql('foo-script');
done();
}
}
Expand Down Expand Up @@ -252,7 +254,7 @@ Lab.experiment('cli', function() {
name: 'service2',
hasScript: function() { return true; },
runScript: function(command) {
Lab.expect(command).to.eql('foo-script');
expect(command).to.eql('foo-script');
done();
}
}
Expand All @@ -275,7 +277,7 @@ Lab.experiment('cli', function() {
Lab.it('runs an interview with a temporary service.json path', function(done) {
// A mock Interview object.
var FakeInterview = function(opts) {
Lab.expect(opts.tmpServiceJsonPath).to.match(/.*\.json/)
expect(opts.tmpServiceJsonPath).to.match(/.*\.json/)
done();
};
FakeInterview.prototype.run = function() {};
Expand Down Expand Up @@ -325,7 +327,7 @@ Lab.experiment('cli', function() {
var cli = Cli({
rimraf: {
sync: function(path) {
Lab.expect(path).to.eql(serviceJsonPath);
expect(path).to.eql(serviceJsonPath);
done();
}
},
Expand Down
26 changes: 14 additions & 12 deletions test/config-test.js
@@ -1,38 +1,40 @@
var _ = require('lodash'),
Lab = require('lab'),
path = require('path'),
lab = require('lab'),
Lab = exports.lab = lab.script(),
expect = lab.expect,
path = require('path'),
Centos = require('../lib/platform-apis/centos'),
Config = require('../lib/config'),
util = require('util');
util = require('util');

Lab.experiment('config', function() {
Lab.it('should be initialized with sane defaults', function(done) {
var config = Config();
Lab.expect(config.baseWorkingDirectory).to.match(/ndm/);
expect(config.baseWorkingDirectory).to.match(/ndm/);
done();
});

Lab.it('should allow defaults to be overridden by opts', function(done) {
var config = Config({
baseWorkingDirectory: '/banana'
});
Lab.expect(config.baseWorkingDirectory).to.eql('/banana');
expect(config.baseWorkingDirectory).to.eql('/banana');
done();
});

Lab.it('should allow defaults to be overridden by environment variables', function(done) {
var config = Config({
env: {NDM_BASE_WORKING_DIRECTORY: '/foo'}
});
Lab.expect(config.baseWorkingDirectory).to.eql('/foo');
expect(config.baseWorkingDirectory).to.eql('/foo');
done();
});

Lab.it('should set OS specific environment variables', function(done) {
var config = Config({
platform: 'darwin'
});
Lab.expect(config.daemonsDirectory).to.eql('~/Library/LaunchAgents/');
expect(config.daemonsDirectory).to.eql('~/Library/LaunchAgents/');
done();
});

Expand All @@ -41,7 +43,7 @@ Lab.experiment('config', function() {
platform: 'darwin',
daemonsDirectory: '/foo'
});
Lab.expect(config.daemonsDirectory).to.eql('/foo');
expect(config.daemonsDirectory).to.eql('/foo');
done();
});

Expand All @@ -52,7 +54,7 @@ Lab.experiment('config', function() {

var config = (require('../lib/config'))();

Lab.expect(config.platform).to.eql('banana');
expect(config.platform).to.eql('banana');
done();
});

Expand All @@ -73,13 +75,13 @@ Lab.experiment('config', function() {
}
});

Lab.expect(config.platform).to.eql('centos');
expect(config.platform).to.eql('centos');
done();
});

Lab.it('should read .ndmrc, and allow default settings to be overridden', function(done) {
var config = Config();
Lab.expect(config.releaseInfoFile).to.eql('/foo/bar/release');
expect(config.releaseInfoFile).to.eql('/foo/bar/release');
done();
});
});

0 comments on commit 386cb63

Please sign in to comment.