Skip to content
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

feat(amazonq): Add command to generate unit tests for selected code #5577

Merged
merged 21 commits into from
Sep 25, 2024

Conversation

bweedop
Copy link
Contributor

@bweedop bweedop commented Sep 11, 2024

Adds command to Amazon Q to generate unit tests for selected code. The feature will be limited to internal Amazon users to collect usage metrics and, subsequently, will be released to all users.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Description

  • Adds "Test" command to context menu (with a (Beta) suffix for while internal only). The command will send the selected code to the chat with the following prompt: "Generate unit tests for the following part of my code for me:"
image

Checklist

  • My code follows the code style of this project
  • I have added tests to cover my changes
  • [] A short description of the change has been added to the CHANGELOG if the change is customer-facing in the IDE.
  • I have added metrics for my changes (if required)

License

I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link

This pull request modifies files in src/ but no tests were added/updated. Confirm whether tests should be added or ensure the PR description explains why tests are not required.

Copy link

This pull request modifies a feature or fixes a bug, but it does not include a changelog entry. All pull requests that introduce new features or bug fixes must have a corresponding changelog item describing the changes.

@bweedop bweedop marked this pull request as ready for review September 17, 2024 18:07
@bweedop bweedop requested review from a team as code owners September 17, 2024 18:07
packages/core/src/codewhisperer/util/authUtil.ts Outdated Show resolved Hide resolved
packages/core/package.nls.json Outdated Show resolved Hide resolved
Copy link

This pull request modifies code in src/ but no tests were added/updated. Confirm whether tests should be added or ensure the PR description explains why tests are not required.

Copy link

This pull request implements a feature or fix, so it must include a changelog entry. See CONTRIBUTING.md#changelog for instructions.

@@ -223,6 +245,8 @@ export class Auth implements AuthService, ConnectionManager {
this.#onDidChangeActiveConnection.fire(conn)
await this.store.setCurrentProfileId(id)

await setContext('aws.isInternalUser', this.isInternalAmazonUser())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering if forgetConnection and expireConnection should also un-set this. But it's probably useful to keep this hint around, once it was deduced. And in that case, should this flag be stored in globalState? Then we don't need to wait until a valid connection next time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it hurts to set this back to false on forgetConnection and expireConnection.

Some testing that I did made me doubt how globalState worked. Using globalState.update for this didn't work to enable the feature for internal users. setContext, however, worked. Are global keys detectable from package.json after being set?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are global keys detectable from package.json after being set?

No

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh okay well that would explain it. We need this to be set with setContext

Copy link
Contributor

@justinmk3 justinmk3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after comments. Needs approval from someone on your team too.

@justinmk3 justinmk3 merged commit 8831e6b into aws:master Sep 25, 2024
21 of 24 checks passed
ivikash pushed a commit to ivikash/aws-toolkit-vscode that referenced this pull request Sep 25, 2024
- Add command to Amazon Q to generate unit tests for selected code. The
  feature will be limited to internal Amazon users, initially.
- Add "Generate Tests" command.
ivikash pushed a commit to ivikash/aws-toolkit-vscode that referenced this pull request Sep 25, 2024
- Add command to Amazon Q to generate unit tests for selected code. The
  feature will be limited to internal Amazon users, initially.
- Add "Generate Tests" command.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants