Files
opentf/website/docs/cli/commands/test/examples/mock_provider/main.tftest.hcl
Oleksandr Levchenkov 9d9a7aab06 add mock providers for testing framework (#1772)
Signed-off-by: ollevche <ollevche@gmail.com>
2024-07-09 14:41:52 +03:00

30 lines
749 B
HCL

// All resources and data sources provided by `aws.mock` provider
// will be mocked. Their values will be automatically generated.
mock_provider "aws" {
alias = "mock"
}
// The same goes for `local` provider. Also, every `local_file`
// data source will have its `content` set to `test`.
mock_provider "local" {
mock_data "local_file" {
defaults = {
content = "test"
}
}
}
// Test if the bucket name is correctly passed to the aws_s3_bucket
// resource from the local file.
run "test" {
// Use `aws.mock` provider for this test run only.
providers = {
aws = aws.mock
}
assert {
condition = aws_s3_bucket.test.bucket == "test"
error_message = "Incorrect bucket name: ${aws_s3_bucket.test.bucket}"
}
}