File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
test/awsService/ec2/explorer Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -52,9 +52,18 @@ export class Ec2ParentNode extends AWSTreeNodeBase {
5252 )
5353 }
5454
55+ public getInstanceNode ( instanceId : string ) : Ec2InstanceNode {
56+ const childNode = this . ec2InstanceNodes . get ( instanceId )
57+ if ( childNode ) {
58+ return childNode
59+ } else {
60+ throw new Error ( `Node with id ${ instanceId } not found` )
61+ }
62+ }
63+
5564 private async updatePendingNodes ( ) {
5665 for ( const instanceId of this . pollingSet . values ( ) ) {
57- const childNode = this . ec2InstanceNodes . get ( instanceId ) !
66+ const childNode = this . getInstanceNode ( instanceId )
5867 await this . updatePendingNode ( childNode )
5968 }
6069 }
Original file line number Diff line number Diff line change @@ -182,4 +182,23 @@ describe('ec2ParentNode', function () {
182182 sinon . assert . called ( refreshStub )
183183 statusUpdateStub . restore ( )
184184 } )
185+
186+ it ( 'returns the node when in the map' , async function ( ) {
187+ const instances = [ { Name : 'firstOne' , InstanceId : 'node1' , LastSeenStatus : 'pending' } ]
188+
189+ getInstanceStub . resolves ( mapToInstanceCollection ( instances ) )
190+ await testNode . updateChildren ( )
191+ const node = testNode . getInstanceNode ( 'node1' )
192+ assert . strictEqual ( node . InstanceId , instances [ 0 ] . InstanceId )
193+ getInstanceStub . restore ( )
194+ } )
195+
196+ it ( 'throws error when node not in map' , async function ( ) {
197+ const instances = [ { Name : 'firstOne' , InstanceId : 'node1' , LastSeenStatus : 'pending' } ]
198+
199+ getInstanceStub . resolves ( mapToInstanceCollection ( instances ) )
200+ await testNode . updateChildren ( )
201+ assert . throws ( ( ) => testNode . getInstanceNode ( 'node2' ) )
202+ getInstanceStub . restore ( )
203+ } )
185204} )
You can’t perform that action at this time.
0 commit comments