Skip to content

fix: mock aws data sources in tests - #26

Merged
gberenice merged 4 commits into
mainfrom
fix/failing-tests
Dec 5, 2025
Merged

fix: mock aws data sources in tests#26
gberenice merged 4 commits into
mainfrom
fix/failing-tests

Conversation

@gberenice

Copy link
Copy Markdown
Member

what

  • Added mock_provider blocks to both test files.
  • Mocked aws_ssm_parameter data source to avoid AWS credential requirements.

why

  • Tests were failing with missing provider errors and AWS authentication issues:
│ Error: Invalid provider configuration
│ 
│ Provider "registry.opentofu.org/hashicorp/aws" requires explicit
│ configuration. Add a provider block to the root module and configure the
│ provider's required arguments as described in the provider documentation.
│ 
╵
tests/locals.tftest.hcl... fail
╷
│ Error: No valid credential sources found
│ 
│   with provider["registry.opentofu.org/hashicorp/aws"],
│   on provider["registry.opentofu.org/hashicorp/aws"] with no configuration line 1:
│   (source code not available)
│ 
│ Please see https://registry.terraform.io/providers/hashicorp/aws
│ for more information about providing credentials.
│ 
│ Error: failed to refresh cached credentials, no EC2 IMDS role found,
│ operation error ec2imds: GetMetadata, failed to get API token, operation
│ error ec2imds: getToken, http response error StatusCode: 400, request to
│ EC2 IMDS failed
│ 
╵
  run "test_empty_secret_mapping"... fail
  run "test_multiple_files_and_secrets"... skip
tests/outputs.tftest.hcl... fail
╷
│ Error: Invalid provider configuration
│ 
│ Provider "registry.opentofu.org/hashicorp/aws" requires explicit
│ configuration. Add a provider block to the root module and configure the
│ provider's required arguments as described in the provider documentation.
│ 
╵
╷
│ Error: No valid credential sources found
│ 
│   with provider["registry.opentofu.org/hashicorp/aws"],
│   on provider["registry.opentofu.org/hashicorp/aws"] with no configuration line 1:
│   (source code not available)
│ 
│ Please see https://registry.terraform.io/providers/hashicorp/aws
│ for more information about providing credentials.
│ 
│ Error: failed to refresh cached credentials, no EC2 IMDS role found,
│ operation error ec2imds: GetMetadata, failed to get API token, operation
│ error ec2imds: getToken, http response error StatusCode: 400, request to
│ EC2 IMDS failed
│ 
╵
  run "test_output_structure_and_content"... fail
  run "test_output_empty_secrets"... skip

Failure! 0 passed, 2 failed, 2 skipped.
Error: Process completed with exit code 1.

references

@gberenice
gberenice requested a review from a team as a code owner October 21, 2025 13:40
@gberenice
gberenice requested a review from Gowiem October 21, 2025 13:40
oycyc
oycyc previously approved these changes Oct 21, 2025

@oycyc oycyc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah that was why!

@gberenice
gberenice force-pushed the fix/failing-tests branch 2 times, most recently from 88fec85 to 9bf71d9 Compare October 21, 2025 16:06
@gberenice

Copy link
Copy Markdown
Member Author

@oycyc please ignore this PR for now. I see a weird issue when the workflow file is valid, while the wrong SHA is used during the tests.
I'll make sure to ping you when this is resolved.
Screenshot 2025-10-21 at 19 00 37
Screenshot 2025-10-21 at 19 00 46

@gberenice
gberenice force-pushed the fix/failing-tests branch 2 times, most recently from a8041db to 0726251 Compare December 5, 2025 16:03
@gberenice

Copy link
Copy Markdown
Member Author

I'm merging and bypassing the rules because we have a chicken-egg problem here. Tests will fail untill I merge the fix into the main.

@gberenice
gberenice merged commit 48c8563 into main Dec 5, 2025
4 of 6 checks passed
@gberenice
gberenice deleted the fix/failing-tests branch December 5, 2025 16:07
gberenice pushed a commit that referenced this pull request Dec 8, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.0.0](v0.3.0...v1.0.0)
(2025-12-08)


### ⚠ BREAKING CHANGES

* **outputs:** breaking change, add sensitive true to outputs + add
tests
([#17](#17))

### Features

* AWS SSM Parameter Store
([#25](#25))
([4f065a3](4f065a3))
* **outputs:** breaking change, add sensitive true to outputs + add
tests
([#17](#17))
([9eff666](9eff666))


### Bug Fixes

* mock aws data sources in tests
([#26](#26))
([48c8563](48c8563))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: masterpointbot[bot] <177651640+masterpointbot[bot]@users.noreply.github.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