Skip to content

Commit

Permalink
test: fix parentNode tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Hweinstock committed Feb 27, 2025
1 parent bda476a commit 9543f86
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const testParentNode = new Ec2ParentNode('fake-region', 'testPartition',
describe('ec2ParentNode', function () {
let testNode: Ec2ParentNode
let client: Ec2Client
let getInstancesStub: sinon.SinonStub<[filters?: Filter[] | undefined], AsyncCollection<PatchedEc2Instance>>
let getInstancesStub: sinon.SinonStub<[filters?: Filter[] | undefined], AsyncCollection<PatchedEc2Instance[]>>
let clock: FakeTimers.InstalledClock
let refreshStub: sinon.SinonStub<[], Promise<void>>
let statusUpdateStub: sinon.SinonStub<[status: string], Promise<string>>
Expand Down Expand Up @@ -78,7 +78,7 @@ describe('ec2ParentNode', function () {
{ Name: 'firstOne', InstanceId: '0', LastSeenStatus: 'running' },
{ Name: 'secondOne', InstanceId: '1', LastSeenStatus: 'stopped' },
] satisfies PatchedEc2Instance[]
getInstancesStub.returns(intoCollection(instances))
getInstancesStub.returns(intoCollection([instances]))
const childNodes = await testNode.getChildren()

assert.strictEqual(childNodes.length, instances.length, 'Unexpected child count')
Expand All @@ -101,7 +101,7 @@ describe('ec2ParentNode', function () {
{ Name: 'cd', InstanceId: '5', LastSeenStatus: 'running' },
] satisfies PatchedEc2Instance[]

getInstancesStub.returns(intoCollection(instances))
getInstancesStub.returns(intoCollection([instances]))

const childNodes = await testNode.getChildren()

Expand All @@ -124,7 +124,7 @@ describe('ec2ParentNode', function () {
{ Name: 'firstOne', InstanceId: '2', LastSeenStatus: 'running' },
] satisfies PatchedEc2Instance[]

getInstancesStub.returns(intoCollection(instances))
getInstancesStub.returns(intoCollection([instances]))

const childNodes = await testNode.getChildren()
assert.strictEqual(childNodes.length, instances.length, 'Unexpected child count')
Expand All @@ -138,7 +138,7 @@ describe('ec2ParentNode', function () {
{ Name: 'thirdOne', InstanceId: '2', LastSeenStatus: 'running' },
] satisfies PatchedEc2Instance[]

getInstancesStub.returns(intoCollection(instances))
getInstancesStub.returns(intoCollection([instances]))
await testNode.updateChildren()
assert.strictEqual(testNode.pollingSet.size, 1)
getInstancesStub.restore()
Expand All @@ -152,7 +152,7 @@ describe('ec2ParentNode', function () {
{ Name: 'thirdOne', InstanceId: '2', LastSeenStatus: 'running' },
] satisfies PatchedEc2Instance[]

getInstancesStub.returns(intoCollection(instances))
getInstancesStub.returns(intoCollection([instances]))

await testNode.updateChildren()
await clock.tickAsync(6000)
Expand All @@ -166,7 +166,7 @@ describe('ec2ParentNode', function () {
{ Name: 'firstOne', InstanceId: '0', LastSeenStatus: 'pending' },
] satisfies PatchedEc2Instance[]

getInstancesStub.returns(intoCollection(instances))
getInstancesStub.returns(intoCollection([instances]))
await testNode.updateChildren()

sinon.assert.notCalled(refreshStub)
Expand All @@ -179,7 +179,7 @@ describe('ec2ParentNode', function () {
{ Name: 'firstOne', InstanceId: 'node1', LastSeenStatus: 'pending' },
] satisfies PatchedEc2Instance[]

getInstancesStub.returns(intoCollection(instances))
getInstancesStub.returns(intoCollection([instances]))
await testNode.updateChildren()
const node = testNode.getInstanceNode('node1')
assert.strictEqual(node.InstanceId, instances[0].InstanceId)
Expand All @@ -191,7 +191,7 @@ describe('ec2ParentNode', function () {
{ Name: 'firstOne', InstanceId: 'node1', LastSeenStatus: 'pending' },
] satisfies PatchedEc2Instance[]

getInstancesStub.returns(intoCollection(instances))
getInstancesStub.returns(intoCollection([instances]))
await testNode.updateChildren()
assert.throws(() => testNode.getInstanceNode('node2'))
getInstancesStub.restore()
Expand All @@ -202,7 +202,7 @@ describe('ec2ParentNode', function () {
{ Name: 'firstOne', InstanceId: 'node1', LastSeenStatus: 'pending' },
] satisfies PatchedEc2Instance[]

getInstancesStub.returns(intoCollection(instances))
getInstancesStub.returns(intoCollection([instances]))
await testNode.updateChildren()
testNode.trackPendingNode('node1')
assert.strictEqual(testNode.pollingSet.size, 1)
Expand All @@ -214,7 +214,7 @@ describe('ec2ParentNode', function () {
{ Name: 'firstOne', InstanceId: 'node1', LastSeenStatus: 'pending' },
] satisfies PatchedEc2Instance[]

getInstancesStub.returns(intoCollection(instances))
getInstancesStub.returns(intoCollection([instances]))
await testNode.updateChildren()
assert.throws(() => testNode.trackPendingNode('node2'))
getInstancesStub.restore()
Expand Down

0 comments on commit 9543f86

Please sign in to comment.