chore: Allow to set provider version in tests

Different AWS terraform state reader resource tests can use different provider versions.
main
Christof Dorner 2022-06-14 17:49:22 +02:00
parent 8a16e8689a
commit 93292f577f
No known key found for this signature in database
GPG Key ID: FE6B8344731C047E
1 changed files with 9 additions and 5 deletions

View File

@ -96,9 +96,10 @@ func TestTerraformStateReader_Source(t *testing.T) {
func TestTerraformStateReader_AWS_Resources(t *testing.T) { func TestTerraformStateReader_AWS_Resources(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
dirName string dirName string
wantErr bool wantErr bool
providerVersion string
}{ }{
{name: "IAM user module", dirName: "module.iam_iam-user", wantErr: false}, {name: "IAM user module", dirName: "module.iam_iam-user", wantErr: false},
{name: "Data source", dirName: "data_source", wantErr: false}, {name: "Data source", dirName: "data_source", wantErr: false},
@ -212,10 +213,13 @@ func TestTerraformStateReader_AWS_Resources(t *testing.T) {
shouldUpdate := tt.dirName == *goldenfile.Update shouldUpdate := tt.dirName == *goldenfile.Update
var realProvider *aws.AWSTerraformProvider var realProvider *aws.AWSTerraformProvider
if tt.providerVersion == "" {
tt.providerVersion = "3.19.0"
}
if shouldUpdate { if shouldUpdate {
var err error var err error
realProvider, err = aws.NewAWSTerraformProvider("3.19.0", progress, os.TempDir()) realProvider, err = aws.NewAWSTerraformProvider(tt.providerVersion, progress, os.TempDir())
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -229,7 +233,7 @@ func TestTerraformStateReader_AWS_Resources(t *testing.T) {
library := terraform.NewProviderLibrary() library := terraform.NewProviderLibrary()
library.AddProvider(terraform.AWS, provider) library.AddProvider(terraform.AWS, provider)
repo := testresource.InitFakeSchemaRepository(terraform.AWS, "3.19.0") repo := testresource.InitFakeSchemaRepository(terraform.AWS, tt.providerVersion)
resourceaws.InitResourcesMetadata(repo) resourceaws.InitResourcesMetadata(repo)
factory := terraform.NewTerraformResourceFactory(repo) factory := terraform.NewTerraformResourceFactory(repo)