@@ -20,13 +20,14 @@ import {
2020import { getTestWindow } from '../../../shared/vscode/window'
2121import { CloudWatchLogsSettings , uriToKey } from '../../../../awsService/cloudWatchLogs/cloudWatchLogsUtils'
2222import { installFakeClock } from '../../../testUtil'
23- import { DefaultAwsContext } from '../../../../shared'
23+ import { DefaultAwsContext , ToolkitError } from '../../../../shared'
2424
2525describe ( 'TailLogGroup' , function ( ) {
2626 const testLogGroup = 'test-log-group'
2727 const testRegion = 'test-region'
2828 const testMessage = 'test-message'
2929 const testAwsAccountId = '1234'
30+ const testAwsCredentials = { } as any as AWS . Credentials
3031
3132 let sandbox : sinon . SinonSandbox
3233 let registry : LiveTailSessionRegistry
@@ -57,6 +58,8 @@ describe('TailLogGroup', function () {
5758
5859 it ( 'starts LiveTailSession and writes to document. Closes tab and asserts session gets closed.' , async function ( ) {
5960 sandbox . stub ( DefaultAwsContext . prototype , 'getCredentialAccountId' ) . returns ( testAwsAccountId )
61+ sandbox . stub ( DefaultAwsContext . prototype , 'getCredentials' ) . returns ( Promise . resolve ( testAwsCredentials ) )
62+
6063 wizardSpy = sandbox . stub ( TailLogGroupWizard . prototype , 'run' ) . callsFake ( async function ( ) {
6164 return getTestWizardResponse ( )
6265 } )
@@ -122,6 +125,19 @@ describe('TailLogGroup', function () {
122125 assert . strictEqual ( stopLiveTailSessionSpy . calledOnce , true )
123126 } )
124127
128+ it ( 'throws if crendentials are undefined' , async function ( ) {
129+ sandbox . stub ( DefaultAwsContext . prototype , 'getCredentials' ) . returns ( Promise . resolve ( undefined ) )
130+ wizardSpy = sandbox . stub ( TailLogGroupWizard . prototype , 'run' ) . callsFake ( async function ( ) {
131+ return getTestWizardResponse ( )
132+ } )
133+ await assert . rejects ( async ( ) => {
134+ await tailLogGroup ( registry , {
135+ groupName : testLogGroup ,
136+ regionName : testRegion ,
137+ } )
138+ } , ToolkitError )
139+ } )
140+
125141 it ( 'closeSession removes session from registry and calls underlying stopLiveTailSession function.' , function ( ) {
126142 stopLiveTailSessionSpy = sandbox
127143 . stub ( LiveTailSession . prototype , 'stopLiveTailSession' )
@@ -132,6 +148,7 @@ describe('TailLogGroup', function () {
132148 const session = new LiveTailSession ( {
133149 logGroupArn : testLogGroup ,
134150 region : testRegion ,
151+ awsCredentials : testAwsCredentials ,
135152 } )
136153 registry . set ( uriToKey ( session . uri ) , session )
137154
@@ -145,6 +162,7 @@ describe('TailLogGroup', function () {
145162 const session = new LiveTailSession ( {
146163 logGroupArn : testLogGroup ,
147164 region : testRegion ,
165+ awsCredentials : testAwsCredentials ,
148166 } )
149167 const testData = 'blah blah blah'
150168 const document = await vscode . workspace . openTextDocument ( session . uri )
0 commit comments