Skip to content

test(storage): fix assert.throws and assert.rejects violations - #9212

Open
thiyaguk09 wants to merge 3 commits into
googleapis:mainfrom
thiyaguk09:fix/storage-test-assertions
Open

test(storage): fix assert.throws and assert.rejects violations#9212
thiyaguk09 wants to merge 3 commits into
googleapis:mainfrom
thiyaguk09:fix/storage-test-assertions

Conversation

@thiyaguk09

Copy link
Copy Markdown
Contributor

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕

@product-auto-label product-auto-label Bot added the api: storage Issues related to the Cloud Storage API. label Aug 26, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors several test files under handwritten/storage/test/ to improve type safety, fix incorrect assertion patterns, and clean up asynchronous code. Notably, it corrects broken assert.throws usages (which previously used comma expressions that did not actually validate the error message) by wrapping the expected error messages in new RegExp(...). It also replaces Promise.resolve().then(...) with process.nextTick(...) for asynchronous callbacks, adds missing await keywords to assert.rejects calls, and replaces any types with more specific types. The review feedback recommends further improving the assert.throws assertions by passing a validation object with a message property (e.g., { message: ... }) instead of using new RegExp(...), which is cleaner, avoids regex compilation overhead, and ensures a strict equality check.

Comment thread handwritten/storage/test/bucket.ts Outdated
Comment thread handwritten/storage/test/file.ts Outdated
Comment thread handwritten/storage/test/signer.ts Outdated
@thiyaguk09
thiyaguk09 marked this pull request as ready for review August 26, 2026 07:24
@thiyaguk09
thiyaguk09 requested a review from a team as a code owner August 26, 2026 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the Cloud Storage API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant