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

Add acceptance test for TF_VAR environment variable usage #58

Merged
merged 1 commit into from
Apr 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions internal/frameworkprovider/resource_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,40 @@ func TestAccFrameworkResourceUser_interpolateLanguage(t *testing.T) {
})
}

// Reference: https://github.com/hashicorp/terraform-plugin-sdk/issues/935
func TestAccFrameworkResourceUser_TF_VAR_Environment_Variable(t *testing.T) {
expectedUserName := "Ford Prefect"
Copy link
Contributor

Choose a reason for hiding this comment

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

LOL - I see what you did there ;)

t.Setenv("TF_VAR_framework_user_name", expectedUserName)

resource.UnitTest(t, resource.TestCase{
ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){
"framework": func() (tfprotov6.ProviderServer, error) {
return tfsdk.NewProtocol6Server(New()), nil
},
},
Steps: []resource.TestStep{
{
Config: `
# Sourced via TF_VAR_framework_user_name environment variable
variable "framework_user_name" {
type = string
}

resource "framework_user" "test" {
email = "ford@prefect.co"
name = var.framework_user_name
age = 200
id = "h"
}
`,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("framework_user.test", "name", expectedUserName),
),
},
},
})
}

const configResourceUserBasic = `
resource "framework_user" "foo" {
email = "ford@prefect.co"
Expand Down