Skip to content

Commit

Permalink
S3UTILS-155: update unit tests for count manager
Browse files Browse the repository at this point in the history
  • Loading branch information
williamlardier committed Mar 25, 2024
1 parent 76efea8 commit 5596b25
Show file tree
Hide file tree
Showing 2 changed files with 187 additions and 22 deletions.
152 changes: 136 additions & 16 deletions tests/unit/CountItems/CountManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,53 +82,173 @@ 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,
},
},
},
},
});
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,
},
},
},
});
Expand Down
57 changes: 51 additions & 6 deletions tests/unit/CountItems/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 5596b25

Please sign in to comment.