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

Testing Feature - Support overrides for data sources / resources / modules #1204

Closed
RLRabinowitz opened this issue Jan 29, 2024 · 0 comments · Fixed by #1499
Closed

Testing Feature - Support overrides for data sources / resources / modules #1204

RLRabinowitz opened this issue Jan 29, 2024 · 0 comments · Fixed by #1499
Assignees
Labels
accepted This issue has been accepted for implementation. enhancement New feature or request
Milestone

Comments

@RLRabinowitz
Copy link
Collaborator

OpenTofu Version

1.6.0

Use Cases

Mocking can be very helpful and powerful when testing. In addition to the request to allow for mocking providers in tests, we should also be able to create more granular mocks, for specific resources / modules / data sources

Attempted Solutions

No way currently to mock specific resources / modules / data sources in test runs

Proposal

Create override_module, override_resource and override_data blocks, which could be defined globally in the test file / under the mock_provider block / under a run block, and could be used to completely override the module/resource/data source.

When using an override_module/override_resource/override_data, this module/resource/data wouldn't actually be created using the provider, it only immediately return with the values/outputs defined in the override block

override_resource {
  target = aws_s3_bucket.my_bucket
  values = {
    body = "my_text"
  }
}

override_data {
  target = data.aws_s3_bucket.my_bucket
  values = {
    body = "my_text"
  }
}

override_module {
  target = module.my_module
  outputs = {
    output1 = "my_output
  }
}

References

@RLRabinowitz RLRabinowitz added enhancement New feature or request pending-decision This issue has not been accepted for implementation nor rejected. It's still open to discussion. labels Jan 29, 2024
@RLRabinowitz RLRabinowitz added this to the 1.7.0 milestone Jan 29, 2024
@cam72cam cam72cam added accepted This issue has been accepted for implementation. and removed pending-decision This issue has not been accepted for implementation nor rejected. It's still open to discussion. labels Feb 1, 2024
@ollevche ollevche self-assigned this Mar 29, 2024
@cube2222 cube2222 modified the milestones: 1.7.0, 1.7.1, 1.8.0 Apr 17, 2024
@ollevche ollevche modified the milestones: 1.7.3, 1.8.0 Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted This issue has been accepted for implementation. enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants