Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should throw an error on all other catches', () => {
// Our own little bad container.
const bogusContainer = new Dockerode.Container();
// Throw the proper error.
const inspectStub = sinon.stub(bogusContainer, 'inspect').rejects(new Error('It\'s a trap!'));
// Make sure we return the proper failing container.
const getStub = sinon.stub(landerode, 'getContainer').returns(bogusContainer);
return landerode.isRunning('foo').should.be
.rejectedWith('It\'s a trap!').then(() => {
getStub.restore();
inspectStub.restore();
});
});
});
it('should return true if State.Running inspect data is true', () => {
// Container to return from 'getContainer';;l
const bogusContainer = new Dockerode.Container({}, 'YT-1300');
// Force the state of the container to be running.
const inspectStub = sinon.stub(bogusContainer, 'inspect').resolves({
State: {
Running: true,
},
});
// Force the return of our container
const getStub = sinon.stub(landerode, 'getContainer').returns(bogusContainer);
return landerode.isRunning('YT-1300').should.eventually.be.true
.then(() => {
inspectStub.restore();
getStub.restore();
});
});
const dummyContainer = (overrides = {}) => {
return _.assign(
new Dockerode.Container(),
{
Id: '8675309',
app: 'Death Star',
Labels: {
'com.docker.compose.project': 'Death Star',
'com.docker.compose.service': 'Exhaust Port',
'com.docker.compose.container-number': 73,
'com.docker.compose.oneoff': 'no',
'io.lando.container': 'TRUE',
'io.lando.src': '/tmp/.lando.yml',
'io.lando.id': 'lando',
'io.lando.service-container': 'no',
},
},
overrides
);