From 5596b256563f91ea98d6cf9155beb5fe0580f4e2 Mon Sep 17 00:00:00 2001 From: williamlardier Date: Mon, 25 Mar 2024 17:50:21 +0100 Subject: [PATCH] S3UTILS-155: update unit tests for count manager --- tests/unit/CountItems/CountManager.js | 152 +++++++++++++++++++++++--- tests/unit/CountItems/utils/utils.js | 57 +++++++++- 2 files changed, 187 insertions(+), 22 deletions(-) diff --git a/tests/unit/CountItems/CountManager.js b/tests/unit/CountItems/CountManager.js index 0ec248e3..4d0c5f8e 100644 --- a/tests/unit/CountItems/CountManager.js +++ b/tests/unit/CountItems/CountManager.js @@ -82,26 +82,86 @@ describe('CountItems::CountManager', () => { dataMetrics: { account: { account1: { - objectCount: { current: 10, deleteMarker: 0, nonCurrent: 10 }, - usedCapacity: { current: 100, nonCurrent: 100 }, + objectCount: { + current: 10, + deleteMarker: 0, + nonCurrent: 10, + currentCold: 0, + nonCurrentCold: 0, + restored: 1, + restoring: 0, + }, + usedCapacity: { + current: 100, + nonCurrent: 100, + currentCold: 0, + nonCurrentCold: 0, + restored: 100, + restoring: 0, + }, locations: { location1: { - objectCount: { current: 10, deleteMarker: 0, nonCurrent: 10 }, - usedCapacity: { current: 100, nonCurrent: 100 }, + objectCount: { + current: 10, + deleteMarker: 0, + nonCurrent: 10, + currentCold: 0, + nonCurrentCold: 0, + restored: 1, + restoring: 0, + }, + usedCapacity: { + current: 100, + nonCurrent: 100, + currentCold: 0, + nonCurrentCold: 0, + restored: 100, + restoring: 0, + }, }, }, }, }, bucket: { bucket1: { - objectCount: { current: 10, deleteMarker: 0, nonCurrent: 10 }, - usedCapacity: { current: 100, nonCurrent: 100 }, + objectCount: { + current: 10, + deleteMarker: 0, + nonCurrent: 10, + currentCold: 0, + nonCurrentCold: 0, + restored: 1, + restoring: 0, + }, + usedCapacity: { + current: 100, + nonCurrent: 100, + currentCold: 0, + nonCurrentCold: 0, + restored: 100, + restoring: 0, + }, }, }, location: { location1: { - objectCount: { current: 10, deleteMarker: 0, nonCurrent: 10 }, - usedCapacity: { current: 100, nonCurrent: 100 }, + objectCount: { + current: 10, + deleteMarker: 0, + nonCurrent: 10, + currentCold: 0, + nonCurrentCold: 0, + restored: 1, + restoring: 0, + }, + usedCapacity: { + current: 100, + nonCurrent: 100, + currentCold: 0, + nonCurrentCold: 0, + restored: 100, + restoring: 0, + }, }, }, }, @@ -109,26 +169,86 @@ describe('CountItems::CountManager', () => { expect(m.dataMetrics).toEqual({ account: { account1: { - objectCount: { current: 10, deleteMarker: 0, nonCurrent: 10 }, - usedCapacity: { current: 100, nonCurrent: 100 }, + objectCount: { + current: 10, + deleteMarker: 0, + nonCurrent: 10, + currentCold: 0, + nonCurrentCold: 0, + restored: 1, + restoring: 0, + }, + usedCapacity: { + current: 100, + nonCurrent: 100, + currentCold: 0, + nonCurrentCold: 0, + restored: 100, + restoring: 0, + }, locations: { location1: { - objectCount: { current: 10, deleteMarker: 0, nonCurrent: 10 }, - usedCapacity: { current: 100, nonCurrent: 100 }, + objectCount: { + current: 10, + deleteMarker: 0, + nonCurrent: 10, + currentCold: 0, + nonCurrentCold: 0, + restored: 1, + restoring: 0, + }, + usedCapacity: { + current: 100, + nonCurrent: 100, + currentCold: 0, + nonCurrentCold: 0, + restored: 100, + restoring: 0, + }, }, }, }, }, bucket: { bucket1: { - objectCount: { current: 10, deleteMarker: 0, nonCurrent: 10 }, - usedCapacity: { current: 100, nonCurrent: 100 }, + objectCount: { + current: 10, + deleteMarker: 0, + nonCurrent: 10, + currentCold: 0, + nonCurrentCold: 0, + restored: 1, + restoring: 0, + }, + usedCapacity: { + current: 100, + nonCurrent: 100, + currentCold: 0, + nonCurrentCold: 0, + restored: 100, + restoring: 0, + }, }, }, location: { location1: { - objectCount: { current: 10, deleteMarker: 0, nonCurrent: 10 }, - usedCapacity: { current: 100, nonCurrent: 100 }, + objectCount: { + current: 10, + deleteMarker: 0, + nonCurrent: 10, + currentCold: 0, + nonCurrentCold: 0, + restored: 1, + restoring: 0, + }, + usedCapacity: { + current: 100, + nonCurrent: 100, + currentCold: 0, + nonCurrentCold: 0, + restored: 100, + restoring: 0, + }, }, }, }); diff --git a/tests/unit/CountItems/utils/utils.js b/tests/unit/CountItems/utils/utils.js index 5188691c..cfa6f2a2 100644 --- a/tests/unit/CountItems/utils/utils.js +++ b/tests/unit/CountItems/utils/utils.js @@ -2,18 +2,63 @@ const { consolidateDataMetrics } = require('../../../../CountItems/utils/utils') describe('CountItems::utils::consolidateDataMetrics', () => { const zeroValueRes = { - usedCapacity: { current: 0, nonCurrent: 0 }, - objectCount: { current: 0, nonCurrent: 0, deleteMarker: 0 }, + usedCapacity: { + current: 0, + nonCurrent: 0, + currentCold: 0, + nonCurrentCold: 0, + restored: 0, + restoring: 0, + }, + objectCount: { + current: 0, + nonCurrent: 0, + deleteMarker: 0, + currentCold: 0, + nonCurrentCold: 0, + restored: 0, + restoring: 0, + }, }; const example1 = { - usedCapacity: { current: 10, nonCurrent: 10 }, - objectCount: { current: 10, nonCurrent: 10, deleteMarker: 10 }, + usedCapacity: { + current: 10, + nonCurrent: 10, + currentCold: 0, + nonCurrentCold: 0, + restored: 0, + restoring: 0, + }, + objectCount: { + current: 10, + nonCurrent: 10, + deleteMarker: 10, + currentCold: 0, + nonCurrentCold: 0, + restored: 0, + restoring: 0, + }, }; const example2 = { - usedCapacity: { current: 20, nonCurrent: 20 }, - objectCount: { current: 20, nonCurrent: 20, deleteMarker: 20 }, + usedCapacity: { + current: 20, + nonCurrent: 20, + currentCold: 0, + nonCurrentCold: 0, + restored: 0, + restoring: 0, + }, + objectCount: { + current: 20, + nonCurrent: 20, + deleteMarker: 20, + currentCold: 0, + nonCurrentCold: 0, + restored: 0, + restoring: 0, + }, }; test('should return zero-value if target and source are both undefined', () => {