mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-06-18 15:28:08 +00:00
Merge pull request #1643 from balena-os/1636-purge-null-volumes
Patch list volumes to always return an array
This commit is contained in:
@ -154,6 +154,6 @@ export async function removeOrphanedVolumes(
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function list(): Promise<VolumeInspectInfo[]> {
|
async function list(): Promise<VolumeInspectInfo[]> {
|
||||||
const allVolumes = await docker.listVolumes();
|
const dockerResponse = await docker.listVolumes();
|
||||||
return _.get(allVolumes, 'Volumes', []);
|
return Array.isArray(dockerResponse.Volumes) ? dockerResponse.Volumes : [];
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import * as mockedDockerode from './lib/mocked-dockerode';
|
|||||||
import * as volumeManager from '../src/compose/volume-manager';
|
import * as volumeManager from '../src/compose/volume-manager';
|
||||||
import log from '../src/lib/supervisor-console';
|
import log from '../src/lib/supervisor-console';
|
||||||
import Volume from '../src/compose/volume';
|
import Volume from '../src/compose/volume';
|
||||||
|
import { VolumeInspectInfo } from 'dockerode';
|
||||||
|
|
||||||
describe('Volume Manager', () => {
|
describe('Volume Manager', () => {
|
||||||
let logDebug: SinonStub;
|
let logDebug: SinonStub;
|
||||||
@ -74,6 +75,16 @@ describe('Volume Manager', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can parse null Volumes', async () => {
|
||||||
|
// Setup volume data
|
||||||
|
// @ts-ignore
|
||||||
|
const volumeData: VolumeInspectInfo[] = null;
|
||||||
|
// Perform test
|
||||||
|
await mockedDockerode.testWithData({ volumes: volumeData }, async () => {
|
||||||
|
await expect(volumeManager.getAll()).to.eventually.deep.equal([]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('gets a Volume for an application', async () => {
|
it('gets a Volume for an application', async () => {
|
||||||
// Setup volume data
|
// Setup volume data
|
||||||
const volumeData = [
|
const volumeData = [
|
||||||
|
Reference in New Issue
Block a user