-
Notifications
You must be signed in to change notification settings - Fork 735
fix(lambda): save params before running sam command when --watch is selected #6089
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1030,6 +1030,91 @@ describe('SAM runSync', () => { | |
| prompterTester.assertCallAll() | ||
| }) | ||
|
|
||
| it('[entry: command palette] specify and save flag (with --watch) should save params before starting SAM process', async () => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 95% of the 100 lines in this test are identical to the test above it. The |
||
| const prompterTester = PrompterTester.init() | ||
| .handleQuickPick('Select a SAM/CloudFormation Template', async (quickPick) => { | ||
| // Need sometime to wait for the template to search for template file | ||
| await quickPick.untilReady() | ||
| assert.strictEqual(quickPick.items[0].label, templateFile.fsPath) | ||
| quickPick.acceptItem(quickPick.items[0]) | ||
| }) | ||
| .handleQuickPick('Specify parameter source for sync', async (picker) => { | ||
| // Need time to check samconfig.toml file and generate options | ||
| await picker.untilReady() | ||
| assert.strictEqual(picker.items[0].label, 'Specify required parameters and save as defaults') | ||
| picker.acceptItem(picker.items[0]) | ||
| }) | ||
| .handleQuickPick('Select a region', (quickPick) => { | ||
| const select = quickPick.items.filter((i) => i.detail === 'us-west-2')[0] | ||
| quickPick.acceptItem(select || quickPick.items[0]) | ||
| }) | ||
| .handleQuickPick('Select a CloudFormation Stack', async (picker) => { | ||
| await picker.untilReady() | ||
| assert.strictEqual(picker.items[2].label, 'stack3') | ||
| picker.acceptItem(picker.items[2]) | ||
| }) | ||
| .handleQuickPick('Specify S3 bucket for deployment artifacts', async (picker) => { | ||
| await picker.untilReady() | ||
| assert.strictEqual(picker.items.length, 2) | ||
| assert.strictEqual(picker.items[0].label, 'Create a SAM CLI managed S3 bucket') | ||
| picker.acceptItem(picker.items[0]) | ||
| }) | ||
| .handleQuickPick('Specify parameters for sync', async (picker) => { | ||
| await picker.untilReady() | ||
| assert.strictEqual(picker.items.length, 9) | ||
| const dependencyLayer = picker.items.filter((item) => item.label === 'Dependency layer')[0] | ||
| const useContainer = picker.items.filter((item) => item.label === 'Use container')[0] | ||
| const watch = picker.items.filter((item) => item.label === 'Watch')[0] | ||
| picker.acceptItems(dependencyLayer, useContainer, watch) | ||
| }) | ||
| .build() | ||
|
|
||
| // Invoke sync command from command palette | ||
| await runSync('code', undefined) | ||
|
|
||
| assert(mockGetSamCliPath.calledOnce) | ||
| assert(mockChildProcessClass.calledOnce) | ||
| assert.deepEqual(mockChildProcessClass.getCall(0).args, [ | ||
| 'sam-cli-path', | ||
| [ | ||
| 'sync', | ||
| '--code', | ||
| '--template', | ||
| `${templateFile.fsPath}`, | ||
| '--stack-name', | ||
| 'stack3', | ||
| '--region', | ||
| 'us-west-2', | ||
| '--no-dependency-layer', | ||
| '--save-params', | ||
| '--dependency-layer', | ||
| '--use-container', | ||
| '--watch', | ||
| ], | ||
| { | ||
| spawnOptions: { | ||
| cwd: projectRoot?.fsPath, | ||
| env: { | ||
| AWS_TOOLING_USER_AGENT: 'AWS-Toolkit-For-VSCode/testPluginVersion', | ||
| SAM_CLI_TELEMETRY: '0', | ||
| }, | ||
| }, | ||
| }, | ||
| ]) | ||
| assert(mockGetSpawnEnv.calledOnce) | ||
| assert(spyRunInterminal.calledOnce) | ||
| assert.deepEqual(spyRunInterminal.getCall(0).args, [mockSamSyncChildProcess, 'sync']) | ||
| assert.strictEqual(spyWriteSamconfigGlobal.callCount, 2) | ||
| assert(spyWriteSamconfigGlobal.calledBefore(spyRunInterminal)) | ||
| // Check telementry | ||
| assertTelemetry('sam_sync', { result: 'Succeeded', source: undefined }) | ||
| assertTelemetryCurried('sam_sync')({ | ||
| syncedResources: 'CodeOnly', | ||
| source: undefined, | ||
| }) | ||
| prompterTester.assertCallAll() | ||
| }) | ||
|
|
||
| it('[entry: template file] specify flag should instantiate correct process in terminal', async () => { | ||
| const prompterTester = PrompterTester.init() | ||
| .handleQuickPick('Specify parameter source for sync', async (picker) => { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "type": "Bug Fix", | ||
| "description": "appBuilder refresh feature doesnt work during sync --watch" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this description meaningful to customers? |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Curious]: Shouldn't we just have the following line before
await runInTerminal(sam, 'sync')?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we could, if there's no specific reason why we added that line after running the command.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding past commit here for historical context:
Above is the reason we only save
stack_nameandregioninfo after deploy/sync process completes. For the case of using--watchwith sync, we can proceed with current approach.