import { of } from 'rxjs';
import { OsdService } from '~/app/shared/api/osd.service';
-import { HddSmartDataV1, NvmeSmartDataV1, SmartDataResult } from '~/app/shared/models/smart';
+import {
+ AtaSmartDataV1,
+ IscsiSmartDataV1,
+ NvmeSmartDataV1,
+ SmartDataResult
+} from '~/app/shared/models/smart';
import { SharedModule } from '~/app/shared/shared.module';
import { configureTestBed } from '~/testing/unit-test-helper';
import { SmartListComponent } from './smart-list.component';
let fixture: ComponentFixture<SmartListComponent>;
let osdService: OsdService;
- const SMART_DATA_HDD_VERSION_1_0: HddSmartDataV1 = require('./fixtures/smart_data_version_1_0_hdd_response.json');
+ const SMART_DATA_ATA_VERSION_1_0: AtaSmartDataV1 = require('./fixtures/smart_data_version_1_0_ata_response.json');
const SMART_DATA_NVME_VERSION_1_0: NvmeSmartDataV1 = require('./fixtures/smart_data_version_1_0_nvme_response.json');
+ const SMART_DATA_SCSI_VERSION_1_0: IscsiSmartDataV1 = require('./fixtures/smart_data_version_1_0_scsi_response.json');
/**
* Sets attributes for _all_ returned devices according to the given path. The syntax is the same
*/
const patchData = (path: string, newValue: any): any => {
return _.reduce(
- _.cloneDeep(SMART_DATA_HDD_VERSION_1_0),
+ _.cloneDeep(SMART_DATA_ATA_VERSION_1_0),
(result: object, dataObj, deviceId) => {
result[deviceId] = _.set<any>(dataObj, path, newValue);
return result;
* of `OsdService`. Determines which data is returned.
*/
const initializeComponentWithData = (
- dataType: 'hdd_v1' | 'nvme_v1',
+ dataType: 'hdd_v1' | 'nvme_v1' | 'hdd_v1_scsi',
patch: { [path: string]: any } = null,
simpleChanges?: SimpleChanges
) => {
- let data: HddSmartDataV1 | NvmeSmartDataV1;
+ let data: AtaSmartDataV1 | NvmeSmartDataV1 | IscsiSmartDataV1;
switch (dataType) {
case 'hdd_v1':
- data = SMART_DATA_HDD_VERSION_1_0;
+ data = SMART_DATA_ATA_VERSION_1_0;
break;
case 'nvme_v1':
data = SMART_DATA_NVME_VERSION_1_0;
break;
+ case 'hdd_v1_scsi':
+ data = SMART_DATA_SCSI_VERSION_1_0;
+ break;
}
if (_.isObject(patch)) {
expect(component).toBeTruthy();
});
- describe('tests HDD version 1.x', () => {
+ describe('tests ATA version 1.x', () => {
beforeEach(() => initializeComponentWithData('hdd_v1'));
it('should return with proper keys', () => {
});
});
+ describe('tests SCSI version 1.x', () => {
+ beforeEach(() => initializeComponentWithData('hdd_v1_scsi'));
+
+ it('should return with proper keys', () => {
+ _.each(component.data, (smartData, _deviceId) => {
+ expect(_.keys(smartData)).toEqual(['info', 'smart', 'device', 'identifier']);
+ });
+ });
+
+ it('should not contain excluded keys in `info`', () => {
+ const excludes = ['scsi_error_counter_log', 'scsi_grown_defect_list'];
+ _.each(component.data, (smartData: SmartDataResult, _deviceId) => {
+ _.each(excludes, (exclude) => expect(smartData.info[exclude]).toBeUndefined());
+ });
+ });
+ });
+
it('should not work for version 2.x', () => {
initializeComponentWithData('nvme_v1', { json_format_version: [2, 0] });
expect(component.data).toEqual({});