Skip to content

Move tests to aws-smithy-mocks#119

Open
simonmarty wants to merge 11 commits intoaws:mainfrom
simonmarty:smithy-mocks
Open

Move tests to aws-smithy-mocks#119
simonmarty wants to merge 11 commits intoaws:mainfrom
simonmarty:smithy-mocks

Conversation

@simonmarty
Copy link
Copy Markdown
Contributor

Issue #, if available:

Description of changes: Accidentally closed #112 on a force push.

Move unit tests to aws-smithy-mocks for easier test coverage.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@simonmarty simonmarty requested a review from a team as a code owner September 22, 2025 15:33
@codecov
Copy link
Copy Markdown

codecov bot commented Sep 22, 2025

Codecov Report

❌ Patch coverage is 97.92746% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.72%. Comparing base (01429bb) to head (0401ce1).

Files with missing lines Patch % Lines
aws_secretsmanager_caching/src/lib.rs 97.92% 8 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #119      +/-   ##
==========================================
+ Coverage   92.14%   92.72%   +0.57%     
==========================================
  Files          14       14              
  Lines        2405     2734     +329     
  Branches     2405     2734     +329     
==========================================
+ Hits         2216     2535     +319     
- Misses        143      150       +7     
- Partials       46       49       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@simonmarty simonmarty force-pushed the main branch 2 times, most recently from de875e6 to cde666a Compare October 25, 2025 00:58
@reyhankoyun reyhankoyun added the safe-to-test Maintainer approval to run integration tests for external contributor PRs. label Nov 25, 2025
@github-actions github-actions bot removed the safe-to-test Maintainer approval to run integration tests for external contributor PRs. label Nov 25, 2025
@simonmarty simonmarty added the safe-to-test Maintainer approval to run integration tests for external contributor PRs. label Apr 2, 2026
@github-actions github-actions bot removed the safe-to-test Maintainer approval to run integration tests for external contributor PRs. label Apr 2, 2026
.unwrap();
match client.get_secret_value(secret_id, None, None, false).await {
Ok(_) => panic!(),
Err(e) => e.to_string().contains("Access to KMS is not allowed"),
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.

This evaluates to a bool that's silently discarded. The test passes even if the error message is completely wrong. I think we need to add assert!():

Err(e) => assert!(e.to_string().contains("Access to KMS is not allowed")),    


let describe_secret =
mock!(aws_sdk_secretsmanager::Client::describe_secret).then_error(|| {
// TODO: Figure out how to set __type
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.

Should this be resolved before merging? The old mock returned raw HTTP with "__type":"AccessDeniedException" which the SDK deserializes into the proper error variant. The new mock uses DescribeSecretError::generic(...) which is an unmodeled error. If the code under test distinguishes AccessDeniedException from other errors, this test is weaker than before. If it doesn't, we should remove the TODO.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Whoops, completely missed that. Will find a way to address the TODO in the next rev.

#[tokio::test]
async fn test_is_current_default_succeeds() {
let client = fake_client(Some(Duration::from_secs(0)), false, None, None);
async fn test_get_cache_is_current_fast_refreshes() {
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.

The is_current tests (test_get_cache_is_current_fast_refreshes, test_is_current_version_id_succeeds, test_is_current_version_stage_succeeds, test_is_current_both_version_id_and_version_stage_succeed) share ~90% identical setup: same GSV mock, same describe mock, same client construction, same assertion loop. A helper that takes optional version_id/version_stage and returns a configured client + mock rules would cut a lot of duplication. The old code had fake_client() for this, looks like we removed it for mock-based tests but didn't replace it.

@reyhankoyun reyhankoyun added the safe-to-test Maintainer approval to run integration tests for external contributor PRs. label Apr 6, 2026
@github-actions github-actions bot removed the safe-to-test Maintainer approval to run integration tests for external contributor PRs. label Apr 6, 2026
Signed-off-by: Simon Marty <martysi@amazon.com>
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.

2 participants