Skip to content

Commit c65c76b

Browse files
committed
update sam utils test
1 parent e2f53bf commit c65c76b

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

packages/core/src/test/shared/sam/utils.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ describe('SAM utils', async function () {
236236
const value1 = 'myStackName'
237237
const value2 = 'myBucketName'
238238

239+
after(async () => {
240+
await globals.context.workspaceState.update(mementoRootKey, {})
241+
})
242+
239243
it('1. getRecentResponse should return undefined when mementoRootKey does not exist', async () => {
240244
assert(!getRecentResponse(nonExistingMementoRootKey, identifier, key1))
241245
})
@@ -244,7 +248,7 @@ describe('SAM utils', async function () {
244248
try {
245249
await updateRecentResponse(mementoRootKey, identifier, key1, value1)
246250
} catch (err) {
247-
assert.fail('Should have succeed')
251+
assert.fail('The execution should have succeeded yet encounter unexpected exception')
248252
}
249253
})
250254

@@ -261,12 +265,12 @@ describe('SAM utils', async function () {
261265
assert.strictEqual(result2, value2)
262266
})
263267

264-
it('5. updateRecentResponse should log when failed to update value', async () => {
268+
it('5. updateRecentResponse should log and swallow exception when fails to update value', async () => {
265269
sinon.stub(globals.context.workspaceState, 'update').rejects(new Error('Error updating value'))
266270
try {
267271
await updateRecentResponse(mementoRootKey, identifier, key2, value2)
268272
} catch (err) {
269-
assert.fail('Should have swallowed exception')
273+
assert.fail('The target function should have handled exception internally')
270274
}
271275
assertLogsContain(`sam: unable to save response at key`, false, 'warn')
272276
sinon.restore()

packages/core/src/test/shared/ui/sam/stackPrompter.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ describe('createStackPrompter', () => {
8080
.returns(vscode.Uri.parse(`https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1`))
8181

8282
// Act
83-
const prompter = createStackPrompter(cfnClient, mementoRootKey)
83+
const prompter = createStackPrompter(cfnClient, mementoRootKey, samSyncUrl)
8484
await new Promise((f) => setTimeout(f, 50))
8585

8686
// Assert
@@ -107,7 +107,7 @@ describe('createStackPrompter', () => {
107107
.returns(vscode.Uri.parse(`https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1`))
108108

109109
// Act
110-
const prompter = createStackPrompter(cfnClient, mementoRootKey)
110+
const prompter = createStackPrompter(cfnClient, mementoRootKey, samSyncUrl)
111111
await new Promise((f) => setTimeout(f, 50))
112112

113113
// Assert

0 commit comments

Comments
 (0)