Skip to content

Commit 3fe229e

Browse files
committed
reorder the child adding
1 parent 54ab49b commit 3fe229e

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

packages/core/src/awsService/ec2/explorer/ec2InstanceNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ export class Ec2InstanceNode extends AWSTreeNodeBase implements AWSResourceNode
2929
public readonly instance: SafeEc2Instance
3030
) {
3131
super('')
32+
this.parent.addChild(this)
3233
this.updateInstance(instance)
3334
this.id = this.InstanceId
34-
this.parent.addChild(this)
3535
}
3636

3737
public updateInstance(newInstance: SafeEc2Instance) {

packages/core/src/test/awsService/ec2/explorer/ec2ParentNode.test.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ describe('ec2ParentNode', function () {
134134
]
135135

136136
getInstanceStub.resolves(mapToInstanceCollection(instances))
137-
138137
await testNode.updateChildren()
139138
assert.strictEqual(testNode.pollingSet.size, 1)
140139
getInstanceStub.restore()
@@ -188,4 +187,23 @@ describe('ec2ParentNode', function () {
188187
assert.throws(() => testNode.getInstanceNode('node2'))
189188
getInstanceStub.restore()
190189
})
190+
191+
it('adds node to polling set when asked to track it', async function () {
192+
const instances = [{ Name: 'firstOne', InstanceId: 'node1', LastSeenStatus: 'pending' }]
193+
194+
getInstanceStub.resolves(mapToInstanceCollection(instances))
195+
await testNode.updateChildren()
196+
testNode.trackPendingNode('node1')
197+
assert.strictEqual(testNode.pollingSet.size, 1)
198+
getInstanceStub.restore()
199+
})
200+
201+
it('throws error when asked to track non-child node', async function () {
202+
const instances = [{ Name: 'firstOne', InstanceId: 'node1', LastSeenStatus: 'pending' }]
203+
204+
getInstanceStub.resolves(mapToInstanceCollection(instances))
205+
await testNode.updateChildren()
206+
assert.throws(() => testNode.trackPendingNode('node2'))
207+
getInstanceStub.restore()
208+
})
191209
})

0 commit comments

Comments
 (0)