-
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1030,6 +1030,93 @@ 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 parameters for deploy', 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('Select an S3 Bucket', async (picker) => { | ||
| await picker.untilReady() | ||
| assert.strictEqual(picker.items.length, 3) | ||
| assert.strictEqual(picker.items[2].label, 'stack-3-bucket') | ||
| picker.acceptItem(picker.items[2]) | ||
| }) | ||
| .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}`, | ||
| '--s3-bucket', | ||
| 'stack-3-bucket', | ||
| '--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) => { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.