Update service and tests to use new

This commit is contained in:
Alex Holliday committed 2024-10-22 10:11:02 +08:00
1 parent 49fe463e95
commit 6f358d297d
2 files changed
+32 -55

No files matched your search

+18 -14
View File
@@ -316,13 +316,15 @@ class NetworkService {
used_bytes: 2, used_bytes: 2,
usage_percent: 0.5, usage_percent: 0.5,
}, },
disk: { disk: [
read_speed_bytes: 3, {
write_speed_bytes: 3, read_speed_bytes: 3,
total_bytes: 10, write_speed_bytes: 3,
free_bytes: 2, total_bytes: 10,
usage_percent: 0.8, free_bytes: 2,
}, usage_percent: 0.8,
},
],
host: { host: {
os: "Linux", os: "Linux",
platform: "Ubuntu", platform: "Ubuntu",
@@ -350,13 +352,15 @@ class NetworkService {
used_bytes: 0, used_bytes: 0,
usage_percent: 0, usage_percent: 0,
}, },
disk: { disk: [
read_speed_bytes: 0, {
write_speed_bytes: 0, read_speed_bytes: 0,
total_bytes: 0, write_speed_bytes: 0,
free_bytes: 0, total_bytes: 0,
usage_percent: 0, free_bytes: 0,
}, usage_percent: 0,
},
],
host: { host: {
os: "", os: "",
platform: "", platform: "",
+14 -41
View File
@@ -688,13 +688,15 @@ describe("networkService - handleHardware", () => {
used_bytes: 2, used_bytes: 2,
usage_percent: 0.5, usage_percent: 0.5,
}, },
disk: { disk: [
read_speed_bytes: 3, {
write_speed_bytes: 3, read_speed_bytes: 3,
total_bytes: 10, write_speed_bytes: 3,
free_bytes: 2, total_bytes: 10,
usage_percent: 0.8, free_bytes: 2,
}, usage_percent: 0.8,
},
],
host: { host: {
os: "Linux", os: "Linux",
platform: "Ubuntu", platform: "Ubuntu",
@@ -714,40 +716,11 @@ describe("networkService - handleHardware", () => {
it("should handle an error Hardware response", async () => { it("should handle an error Hardware response", async () => {
logAndStoreCheckStub.throws(new Error("Hardware error")); logAndStoreCheckStub.throws(new Error("Hardware error"));
await networkService.handleHardware(jobMock); try {
const nullData = { await networkService.handleHardware(jobMock);
monitorId: job.data._id, } catch (error) {
cpu: { expect(error.message).to.equal("Hardware error");
physical_core: 0, }
logical_core: 0,
frequency: 0,
temperature: 0,
free_percent: 0,
usage_percent: 0,
},
memory: {
total_bytes: 0,
available_bytes: 0,
used_bytes: 0,
usage_percent: 0,
},
disk: {
read_speed_bytes: 0,
write_speed_bytes: 0,
total_bytes: 0,
free_bytes: 0,
usage_percent: 0,
},
host: {
os: "",
platform: "",
kernel_version: "",
},
};
expect(
logAndStoreCheckStub.calledWith(nullData, networkService.db.createHardwareCheck)
).to.be.true;
}); });
}); });