-
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(api): storage widget showing 0 when host mount is explicit
- add testing for storage data
- Loading branch information
1 parent
538fdc6
commit c413305
Showing
22 changed files
with
459 additions
and
92 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { expect } from 'chai'; | ||
import { mapToStorageOutput } from '../src/dynamic-info'; | ||
import { TEST_CASE_1 } from './test-cases'; | ||
|
||
describe('Dynamic Info', () => { | ||
describe('Storage', () => { | ||
it('Test Case 1', () => { | ||
const output = mapToStorageOutput( | ||
TEST_CASE_1.layout, | ||
//@ts-ignore | ||
TEST_CASE_1.blocks, | ||
TEST_CASE_1.sizes | ||
); | ||
|
||
expect(output).to.deep.equal({ layout: [{ load: 185203033088 }] }); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { expect } from 'chai'; | ||
import { mapToStorageLayout } from '../src/static-info'; | ||
import { TEST_CASE_1 } from './test-cases'; | ||
|
||
describe('Static Info', () => { | ||
describe('Storage', () => { | ||
it('Test Case 1', () => { | ||
const output = mapToStorageLayout( | ||
TEST_CASE_1.disks, | ||
//@ts-ignore | ||
TEST_CASE_1.blocks, | ||
TEST_CASE_1.sizes | ||
); | ||
|
||
expect(output).to.deep.equal(TEST_CASE_1.layout); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
export const TEST_CASE_1 = { | ||
disks: [ | ||
{ | ||
device: '/dev/sda', | ||
type: 'HD', | ||
name: 'QEMU HARDDISK ', | ||
vendor: 'QEMU', | ||
size: 429496729600, | ||
bytesPerSector: null, | ||
totalCylinders: null, | ||
totalHeads: null, | ||
totalSectors: null, | ||
totalTracks: null, | ||
tracksPerCylinder: null, | ||
sectorsPerTrack: null, | ||
firmwareRevision: '2.5+', | ||
serialNum: '', | ||
interfaceType: '', | ||
smartStatus: 'unknown', | ||
temperature: null, | ||
}, | ||
], | ||
sizes: [ | ||
{ | ||
fs: 'overlay', | ||
type: 'overlay', | ||
size: 429236563968, | ||
used: 185197596672, | ||
available: 244022190080, | ||
use: 43.15, | ||
mount: '/', | ||
}, | ||
{ | ||
fs: '/dev/sda1', | ||
type: 'ext4', | ||
size: 429236563968, | ||
used: 185197596672, | ||
available: 244022190080, | ||
use: 43.15, | ||
mount: '/mnt/host', | ||
}, | ||
{ | ||
fs: '/dev/sda15', | ||
type: 'vfat', | ||
size: 109422592, | ||
used: 5436416, | ||
available: 103986176, | ||
use: 4.97, | ||
mount: '/mnt/host/boot/efi', | ||
}, | ||
{ | ||
fs: '/dev/loop3', | ||
type: 'squashfs', | ||
size: 49283072, | ||
used: 49283072, | ||
available: 0, | ||
use: 100, | ||
mount: '/mnt/host/snap/snapd/16010', | ||
}, | ||
{ | ||
fs: '/dev/loop6', | ||
type: 'squashfs', | ||
size: 49283072, | ||
used: 49283072, | ||
available: 0, | ||
use: 100, | ||
mount: '/mnt/host/snap/snapd/16292', | ||
}, | ||
{ | ||
fs: '/dev/loop5', | ||
type: 'squashfs', | ||
size: 108134400, | ||
used: 108134400, | ||
available: 0, | ||
use: 100, | ||
mount: '/mnt/host/snap/lxd/23367', | ||
}, | ||
{ | ||
fs: '/dev/loop2', | ||
type: 'squashfs', | ||
size: 65011712, | ||
used: 65011712, | ||
available: 0, | ||
use: 100, | ||
mount: '/mnt/host/snap/core20/1593', | ||
}, | ||
{ | ||
fs: '/dev/loop4', | ||
type: 'squashfs', | ||
size: 65011712, | ||
used: 65011712, | ||
available: 0, | ||
use: 100, | ||
mount: '/mnt/host/snap/core20/1611', | ||
}, | ||
{ | ||
fs: '/dev/loop7', | ||
type: 'squashfs', | ||
size: 114032640, | ||
used: 114032640, | ||
available: 0, | ||
use: 100, | ||
mount: '/mnt/host/snap/lxd/23537', | ||
}, | ||
], | ||
blocks: [ | ||
{ | ||
name: 'sda', | ||
type: 'disk', | ||
fsType: '', | ||
mount: '', | ||
size: 429496729600, | ||
physical: 'HDD', | ||
uuid: '', | ||
label: '', | ||
model: 'QEMU HARDDISK ', | ||
serial: '', | ||
removable: false, | ||
protocol: '', | ||
group: undefined, | ||
}, | ||
{ | ||
name: 'sda1', | ||
type: 'part', | ||
fsType: 'ext4', | ||
mount: '/mnt/host', | ||
size: 429380320768, | ||
physical: '', | ||
uuid: '43d2b5d9-3af2-48e8-908f-9b975e8974d6', | ||
label: 'cloudimg-rootfs', | ||
model: '', | ||
serial: '', | ||
removable: false, | ||
protocol: '', | ||
group: undefined, | ||
}, | ||
{ | ||
name: 'sda14', | ||
type: 'part', | ||
fsType: '', | ||
mount: '', | ||
size: 4194304, | ||
physical: '', | ||
uuid: '', | ||
label: '', | ||
model: '', | ||
serial: '', | ||
removable: false, | ||
protocol: '', | ||
group: undefined, | ||
}, | ||
{ | ||
name: 'sda15', | ||
type: 'part', | ||
fsType: 'vfat', | ||
mount: '/mnt/host/boot/efi', | ||
size: 111149056, | ||
physical: '', | ||
uuid: '9DDD-AECA', | ||
label: 'UEFI', | ||
model: '', | ||
serial: '', | ||
removable: false, | ||
protocol: '', | ||
group: undefined, | ||
}, | ||
{ | ||
name: 'sr0', | ||
type: 'rom', | ||
fsType: 'iso9660', | ||
mount: '', | ||
size: 4194304, | ||
physical: 'CD/DVD', | ||
uuid: '2021-12-31-15-47-20-00', | ||
label: 'cidata', | ||
model: 'QEMU DVD-ROM ', | ||
serial: '', | ||
removable: true, | ||
protocol: 'ata', | ||
group: undefined, | ||
}, | ||
], | ||
layout: [{ device: 'sda', brand: 'QEMU', size: 429496729600, type: 'HD' }], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* eslint-disable */ | ||
export default { | ||
displayName: 'api', | ||
preset: '../../jest.preset.js', | ||
globals: { | ||
'ts-jest': { | ||
tsconfig: '<rootDir>/tsconfig.spec.json', | ||
}, | ||
}, | ||
testEnvironment: 'node', | ||
transform: { | ||
'^.+\\.[tj]s$': 'ts-jest', | ||
}, | ||
moduleFileExtensions: ['ts', 'js', 'html'], | ||
coverageDirectory: '../../coverage/apps/temp-api', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.