mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-04-24 21:09:47 +00:00
Fix locking stubs that were returning Bluebird
rather than Promise
Change-type: patch
This commit is contained in:
parent
ae756cfabe
commit
d587a323f2
@ -1,5 +1,4 @@
|
|||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import * as Bluebird from 'bluebird';
|
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import {
|
import {
|
||||||
stub,
|
stub,
|
||||||
@ -419,9 +418,9 @@ describe('SupervisorAPI [V1 Endpoints]', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return 423 and reject the reboot if no locks are set', async () => {
|
it('should return 423 and reject the reboot if no locks are set', async () => {
|
||||||
stub(updateLock, 'lock').callsFake((__, opts, fn) => {
|
stub(updateLock, 'lock').callsFake(async (__, opts, fn) => {
|
||||||
if (opts.force) {
|
if (opts.force) {
|
||||||
return Bluebird.resolve(fn());
|
return fn();
|
||||||
}
|
}
|
||||||
throw new UpdatesLockedError('Updates locked');
|
throw new UpdatesLockedError('Updates locked');
|
||||||
});
|
});
|
||||||
@ -457,9 +456,9 @@ describe('SupervisorAPI [V1 Endpoints]', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return 202 and reboot if force is set to true', async () => {
|
it('should return 202 and reboot if force is set to true', async () => {
|
||||||
stub(updateLock, 'lock').callsFake((__, opts, fn) => {
|
stub(updateLock, 'lock').callsFake(async (__, opts, fn) => {
|
||||||
if (opts.force) {
|
if (opts.force) {
|
||||||
return Bluebird.resolve(fn());
|
return fn();
|
||||||
}
|
}
|
||||||
throw new UpdatesLockedError('Updates locked');
|
throw new UpdatesLockedError('Updates locked');
|
||||||
});
|
});
|
||||||
@ -584,9 +583,9 @@ describe('SupervisorAPI [V1 Endpoints]', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return 423 and reject the reboot if locks are set', async () => {
|
it('should return 423 and reject the reboot if locks are set', async () => {
|
||||||
stub(updateLock, 'lock').callsFake((__, opts, fn) => {
|
stub(updateLock, 'lock').callsFake(async (__, opts, fn) => {
|
||||||
if (opts.force) {
|
if (opts.force) {
|
||||||
return Bluebird.resolve(fn());
|
return fn();
|
||||||
}
|
}
|
||||||
throw new UpdatesLockedError('Updates locked');
|
throw new UpdatesLockedError('Updates locked');
|
||||||
});
|
});
|
||||||
@ -622,9 +621,9 @@ describe('SupervisorAPI [V1 Endpoints]', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return 202 and shutdown if force is set to true', async () => {
|
it('should return 202 and shutdown if force is set to true', async () => {
|
||||||
stub(updateLock, 'lock').callsFake((__, opts, fn) => {
|
stub(updateLock, 'lock').callsFake(async (__, opts, fn) => {
|
||||||
if (opts.force) {
|
if (opts.force) {
|
||||||
return Bluebird.resolve(fn());
|
return fn();
|
||||||
}
|
}
|
||||||
throw new UpdatesLockedError('Updates locked');
|
throw new UpdatesLockedError('Updates locked');
|
||||||
});
|
});
|
||||||
@ -969,9 +968,9 @@ describe('SupervisorAPI [V1 Endpoints]', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('prevents patch if update locks are present', async () => {
|
it('prevents patch if update locks are present', async () => {
|
||||||
stub(updateLock, 'lock').callsFake((__, opts, fn) => {
|
stub(updateLock, 'lock').callsFake(async (__, opts, fn) => {
|
||||||
if (opts.force) {
|
if (opts.force) {
|
||||||
return Bluebird.resolve(fn());
|
return fn();
|
||||||
}
|
}
|
||||||
throw new UpdatesLockedError('Updates locked');
|
throw new UpdatesLockedError('Updates locked');
|
||||||
});
|
});
|
||||||
@ -998,9 +997,9 @@ describe('SupervisorAPI [V1 Endpoints]', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('allows patch while update locks are present if force is in req.body', async () => {
|
it('allows patch while update locks are present if force is in req.body', async () => {
|
||||||
stub(updateLock, 'lock').callsFake((__, opts, fn) => {
|
stub(updateLock, 'lock').callsFake(async (__, opts, fn) => {
|
||||||
if (opts.force) {
|
if (opts.force) {
|
||||||
return Bluebird.resolve(fn());
|
return fn();
|
||||||
}
|
}
|
||||||
throw new UpdatesLockedError('Updates locked');
|
throw new UpdatesLockedError('Updates locked');
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { stub, SinonStub, spy, SinonSpy } from 'sinon';
|
import { stub, SinonStub, spy, SinonSpy } from 'sinon';
|
||||||
import * as supertest from 'supertest';
|
import * as supertest from 'supertest';
|
||||||
import * as Bluebird from 'bluebird';
|
|
||||||
|
|
||||||
import sampleResponses = require('~/test-data/device-api-responses.json');
|
import sampleResponses = require('~/test-data/device-api-responses.json');
|
||||||
import mockedAPI = require('~/test-lib/mocked-device-api');
|
import mockedAPI = require('~/test-lib/mocked-device-api');
|
||||||
@ -407,9 +406,13 @@ describe('SupervisorAPI [V2 Endpoints]', () => {
|
|||||||
|
|
||||||
const mockContainers = [mockedAPI.mockService(service)];
|
const mockContainers = [mockedAPI.mockService(service)];
|
||||||
const mockImages = [mockedAPI.mockImage(service)];
|
const mockImages = [mockedAPI.mockImage(service)];
|
||||||
const lockFake = (_: any, opts: { force: boolean }, fn: () => any) => {
|
const lockFake = async (
|
||||||
|
_: any,
|
||||||
|
opts: { force: boolean },
|
||||||
|
fn: () => any,
|
||||||
|
) => {
|
||||||
if (opts.force) {
|
if (opts.force) {
|
||||||
return Bluebird.resolve(fn());
|
return fn();
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new UpdatesLockedError('Updates locked');
|
throw new UpdatesLockedError('Updates locked');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user