describe('#__get', () => { it('should be the same as new NodeCache().get', () => { filesystem(); const cache = new Cache(); cache.set('yyz', 'amazing'); const nCache = new NodeCache(); nCache.set('yyz', 'amazing'); cache.__get('yyz').should.eql(nCache.get('yyz')); filesystem.restore(); }); });
describe('#__set', () => { it('should be the same as new NodeCache().set', () => { filesystem(); const cache = new Cache(); const nCache = new NodeCache(); cache.__set('yyz', 'amazing').should.eql(nCache.set('yyz', 'amazing')); filesystem.restore(); }); });
describe('#which', () => { const savePath = process.env.PATH; beforeEach(() => { process.env.PATH = os.tmpdir(); const bin = {}; const content = 'Gorillaz on buildings throwing explosive bananas at each other with mathematical precision'; bin[path.join(os.tmpdir(), 'GORILLA.BAS')] = content; filesystem(bin); }); it('should return the same as shelljs.which', () => { const shell = new Shell(); const which1 = shell.which('GORILLA.BAS'); const which2 = _shell.which('GORILLA.BAS'); _.toString(which1).should.equal(_.toString(which2)); }); it('should return null if command is not found', () => { const shell = new Shell(); const wolfenstein = shell.which('WOLFENSTEIN2D.exe'); expect(wolfenstein).to.be.null; }); afterEach(() => { filesystem.restore(); process.env.PATH = savePath; }); });
describe('#loadFiles', () => { it('should return an empty object if no files are specified', () => { const fileConfig = config.loadFiles(); expect(fileConfig).to.be.empty; }); it('should return data only from files that exist', () => { filesystem({'/tmp/config1.yml': 'obiwan: kenobi'}); const fileConfig = config.loadFiles(['/tmp/config1.yml', '/tmp/doesnotexist.yml']); expect(hasher(fileConfig)).to.equal(hasher({obiwan: 'kenobi'})); filesystem.restore(); }); it('should give priority to the last file loaded', () => { filesystem({ '/tmp/config1.yml': 'scoundrel: lando', '/tmp/config2.yml': 'scoundrel: solo', }); const fileConfig = config.loadFiles(['/tmp/config1.yml', '/tmp/config2.yml']); expect(hasher(fileConfig)).to.equal(hasher({scoundrel: 'solo'})); filesystem.restore(); }); });
filesystem.restore(); });
describe('#Lando', () => { // @todo: do we need a stronger test? presumably downstream requires handle that? it('should return a Lando instance with correct default options', () => { const lando = new Lando(); lando.should.be.an.instanceof(Lando); }); it('should use prexisting instance id if possible', () => { filesystem({ '/tmp/cache/id': '"24601"', }); const lando = new Lando({userConfRoot: '/tmp'}); lando.config.id.should.equal('24601'); lando.config.user.should.equal('24601'); filesystem.restore(); }); it('should set and persitent cache an instance id if needed', () => { filesystem(); const lando = new Lando({userConfRoot: os.tmpdir()}); const idPath = path.join(lando.config.userConfRoot, 'cache', 'id'); fs.existsSync(idPath).should.be.true; lando.cache.get('id').should.equal(lando.config.id); filesystem.restore(); }); });
const dockerExecutable = env.getDockerExecutable(); expect(dockerExecutable).to.equal('/usr/bin/docker'); filesystem.restore(); resetPlatform(); }); const dockerExecutable = env.getDockerExecutable(); expect(dockerExecutable).to.equal('/Applications/Docker.app/Contents/Resources/bin/docker'); filesystem.restore(); resetPlatform(); }); expect(_.isString(dockerExecutable)).to.equal(true); expect(path.parse(dockerExecutable)).to.be.an('Object'); filesystem.restore(); process.env.PATH = OLDPATH; resetPlatform();
log.transports[transport].should.have.property('level', 'warn'); }); filesystem.restore(); }); });
.should.eventually.be.an('Array').with.a.lengthOf(1) .then(() => { listStub.restore(); }); }); .should.eventually.be.an('Array').with.a.lengthOf(1) .then(() => { listStub.restore(); }); }); .should.eventually.be.an('Array').with.a.lengthOf(1) .then(() => { listStub.restore(); }); }); .should.eventually.be.an('Array').with.a.lengthOf(1) .then(() => { listStub.restore(); }); }); return listStub.restore(); }); filesystem.restore(); });
describe('#__del', () => { it('should be the same as new NodeCache().del', () => { filesystem(); const cache = new Cache(); const nCache = new NodeCache(); cache.__set('yyz', 'amazing'); const returnone = cache.__del('yyz'); nCache.set('yyz', 'amazing'); const returntwo = nCache.del('yyz'); returnone.should.eql(returntwo); filesystem.restore(); }); });
const composeExecutable = env.getComposeExecutable(); expect(composeExecutable).to.equal('/usr/share/lando/bin/docker-compose'); filesystem.restore(); resetPlatform(); }); .to .equal('/Applications/Docker.app/Contents/Resources/bin/docker-compose/docker-compose'); filesystem.restore(); resetPlatform(); }); expect(_.isString(composeExecutable)).to.equal(true); expect(path.parse(composeExecutable)).to.be.an('Object'); filesystem.restore(); process.env.PATH = OLDPATH; resetPlatform();