describe('get /api/v1/service/caldav/sync', () => { it('should sync', async () => { caldavService.syncUserCalendars.resolves({}); const caldavController = CaldavController(caldavService); const req = { user: { id: userId, }, }; await caldavController['get /api/v1/service/caldav/sync'].controller(req, res); assert.calledWith(caldavService.syncUserCalendars, userId); }); });
const getSample = () => { const getMock = sinon .stub() .onFirstCall() .resolves({data: 'some-token'}) .onSecondCall() .resolves({data: 'function-response'}); const axiosMock = {get: getMock}; const resMock = {}; resMock.status = sinon.stub().returns(resMock); resMock.send = sinon.stub().returns(resMock); return { sample: proxyquire('../', { axios: axiosMock, }), mocks: { res: resMock, axios: axiosMock, }, }; }
describe('#createNetwork', () => { it('should merge name correctly into opts', () => { const stub = sinon.stub(landerode, 'createNetwork') .usingPromise(Promise) .resolves(); return landerode.createNet('elthree', {}).then(() => { // for some reason should/expect doesn't work here... stub.calledWith({Name: 'elthree'}); stub.restore(); }); }); it('should throw an error if can\'t create network', () => { const stub = sinon.stub(landerode, 'createNetwork').rejects('Too Many Capes'); return landerode.createNet('hardtimes').should.be.rejectedWith('Too Many Capes') .then(() => { stub.restore(); }); }); });
const listStub = sinon.stub(landerode, 'listContainers') .usingPromise(Promise) .resolves([ dummyContainer({Status: 'Being Awesome'}), dummyContainer({Status: 'Removal In Progress'}), const listStub = sinon.stub(landerode, 'listContainers') .usingPromise(Promise) .resolves([ null, dummyContainer({identity: 'Solo'}), const listStub = sinon.stub(landerode, 'listContainers') .usingPromise(Promise) .resolves([ dummyContainer({Labels: {'io.lando.container': 'FALSE'}}), dummyContainer(), const listStub = sinon.stub(landerode, 'listContainers') .usingPromise(Promise) .resolves([ dummyContainer({Labels: { 'com.docker.compose.project': 'alderaan', let container = dummyContainer(); delete container.lando; const listStub = sinon.stub(landerode, 'listContainers').resolves([container]);
json: sinon.stub().returns(bodyJson), }; const sample = getSample(sinon.stub().resolves(body)); json: sinon.stub().resolves({access_token: 'default-access-token'}), }; const signJsonClaimRes = { json: sinon.stub().resolves({signature: 'default-jwt-signature'}), }; const getTokenRes = { json: sinon.stub().resolves({id_token: 'default-id-token'}), }; const makeIapPostRequestRes = { ok: false, text: sinon.stub().resolves(expectedMsg), }; const FetchStub = sinon .stub() .onCall(0) .resolves(serviceAccountAccessTokenRes) .onCall(1) .resolves(signJsonClaimRes) .onCall(2) .resolves(getTokenRes) .onCall(3) .resolves(makeIapPostRequestRes); const sample = getSample(FetchStub); try {
it('restart', async function () { const restart = sinon.stub().resolves(); const instance = new Instance({}, {environment: 'testing'}, '/var/www/ghost'); instance._process = { name: 'local', restart }; await instance.restart(); expect(restart.calledOnceWithExactly('/var/www/ghost', 'testing')).to.be.true; });
it('skips checking parent folder permissions if local process manager is used', function () { const accessStub = sinon.stub(fs, 'access').resolves(); const checkDirectoryStub = sinon.stub().resolves(); const installFolderPermissions = proxyquire(modulePath, { './check-directory': checkDirectoryStub }).task; return installFolderPermissions({instance: {process: {name: 'local'}}}).then(() => { expect(accessStub.calledOnce).to.be.true; expect(checkDirectoryStub.called).to.be.false; }); });
it('skips checking parent folder permissions if os is not linux', function () { const accessStub = sinon.stub(fs, 'access').resolves(); const checkDirectoryStub = sinon.stub().resolves(); const installFolderPermissions = proxyquire(modulePath, { './check-directory': checkDirectoryStub }).task; const ctx = {system: {platform: {linux: false}}}; return installFolderPermissions(ctx).then(() => { expect(accessStub.calledOnce).to.be.true; expect(checkDirectoryStub.called).to.be.false; }); });