diff --git a/.golangci.yml b/.golangci.yml index cce5cda5..b3cb2898 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,13 +1,13 @@ issues: - max-per-linter: 0 + max-issues-per-linter: 0 max-same-issues: 0 linters: disable-all: true enable: + - copyloopvar - durationcheck - errcheck - - exportloopref - forcetypeassert - gofmt - gosimple @@ -19,10 +19,10 @@ linters: - paralleltest - predeclared - staticcheck - - tenv - unconvert - unparam - unused + - usetesting run: # Prevent false positive timeouts in CI diff --git a/go.mod b/go.mod index 3a81a755..b8b0083c 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,8 @@ module github.com/hashicorp/terraform-plugin-codegen-openapi -go 1.22.7 -toolchain go1.23.1 +go 1.23.0 + +toolchain go1.24.0 require ( github.com/google/go-cmp v0.6.0 diff --git a/internal/cmd/generate_test.go b/internal/cmd/generate_test.go index fa879c27..9327490e 100644 --- a/internal/cmd/generate_test.go +++ b/internal/cmd/generate_test.go @@ -10,6 +10,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/cli" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/cmd" ) @@ -48,7 +49,7 @@ func TestGenerate_WithConfig(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/config/parse_test.go b/internal/config/parse_test.go index e7307606..f15104d1 100644 --- a/internal/config/parse_test.go +++ b/internal/config/parse_test.go @@ -186,7 +186,7 @@ data_sources: }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -448,7 +448,7 @@ data_sources: }, } for name, testCase := range testCases { - name, testCase := name, testCase + errRegex := regexp.MustCompile(testCase.expectedErrRegex) t.Run(name, func(t *testing.T) { diff --git a/internal/explorer/config_explorer_test.go b/internal/explorer/config_explorer_test.go index 36fa2cf1..d929c6f8 100644 --- a/internal/explorer/config_explorer_test.go +++ b/internal/explorer/config_explorer_test.go @@ -8,9 +8,10 @@ import ( "fmt" "testing" + "gopkg.in/yaml.v3" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/config" "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" - "gopkg.in/yaml.v3" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" @@ -321,13 +322,12 @@ func Test_ConfigExplorer_FindResources(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() - explorer := explorer.NewConfigExplorer(high.Document{Paths: &high.Paths{PathItems: testCase.pathItems}}, testCase.config) - got, err := explorer.FindResources() + configExplorer := explorer.NewConfigExplorer(high.Document{Paths: &high.Paths{PathItems: testCase.pathItems}}, testCase.config) + got, err := configExplorer.FindResources() if testCase.expectedErr != nil { if err == nil { @@ -515,13 +515,12 @@ func Test_ConfigExplorer_FindDataSources(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() - explorer := explorer.NewConfigExplorer(high.Document{Paths: &high.Paths{PathItems: testCase.pathItems}}, testCase.config) - got, err := explorer.FindDataSources() + configExplorer := explorer.NewConfigExplorer(high.Document{Paths: &high.Paths{PathItems: testCase.pathItems}}, testCase.config) + got, err := configExplorer.FindDataSources() if testCase.expectedErr != nil { if err == nil { @@ -576,7 +575,6 @@ func Test_ConfigExplorer_FindProvider(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -586,8 +584,8 @@ func Test_ConfigExplorer_FindProvider(t *testing.T) { t.Fatal(err) } - explorer := explorer.NewConfigExplorer(oasModel, testCase.config) - got, err := explorer.FindProvider() + configExplorer := explorer.NewConfigExplorer(oasModel, testCase.config) + got, err := configExplorer.FindProvider() if err != nil { t.Fatalf("was not expecting error, got: %s", err) diff --git a/internal/explorer/explorer_utils_test.go b/internal/explorer/explorer_utils_test.go index 3414d19d..41519efa 100644 --- a/internal/explorer/explorer_utils_test.go +++ b/internal/explorer/explorer_utils_test.go @@ -8,9 +8,11 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/util" + "github.com/google/go-cmp/cmp/cmpopts" "github.com/pb33f/libopenapi/datamodel/high/base" high "github.com/pb33f/libopenapi/datamodel/high/v3" + + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/util" ) func TestReadOpParameters_Resource(t *testing.T) { @@ -324,7 +326,6 @@ func TestReadOpParameters_Resource(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -335,7 +336,7 @@ func TestReadOpParameters_Resource(t *testing.T) { mergedParameters := resource.ReadOpParameters() - if diff := cmp.Diff(mergedParameters, testCase.want, cmp.AllowUnexported(base.Schema{}, base.SchemaProxy{}, sync.Mutex{}, high.Parameter{})); diff != "" { + if diff := cmp.Diff(mergedParameters, testCase.want, cmpopts.IgnoreUnexported(sync.Mutex{}), cmp.AllowUnexported(base.Schema{}, base.SchemaProxy{}, high.Parameter{})); diff != "" { t.Errorf("unexpected difference for resource: %s", diff) } }) @@ -653,7 +654,7 @@ func TestReadOpParameters_DataSource(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -664,7 +665,7 @@ func TestReadOpParameters_DataSource(t *testing.T) { mergedParameters := dataSource.ReadOpParameters() - if diff := cmp.Diff(mergedParameters, testCase.want, cmp.AllowUnexported(base.Schema{}, base.SchemaProxy{}, sync.Mutex{}, high.Parameter{})); diff != "" { + if diff := cmp.Diff(mergedParameters, testCase.want, cmpopts.IgnoreUnexported(sync.Mutex{}), cmp.AllowUnexported(base.Schema{}, base.SchemaProxy{}, high.Parameter{})); diff != "" { t.Errorf("unexpected difference for data source: %s", diff) } }) diff --git a/internal/explorer/guesstimator_explorer_test.go b/internal/explorer/guesstimator_explorer_test.go index 0c42c7b7..9ac60b29 100644 --- a/internal/explorer/guesstimator_explorer_test.go +++ b/internal/explorer/guesstimator_explorer_test.go @@ -96,7 +96,6 @@ func Test_GuesstimatorExplorer_FindResources(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -196,7 +195,6 @@ func Test_GuesstimatorExplorer_FindDataSources(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/attrmapper/bool_test.go b/internal/mapper/attrmapper/bool_test.go index 5078eba9..a9ba5b0f 100644 --- a/internal/mapper/attrmapper/bool_test.go +++ b/internal/mapper/attrmapper/bool_test.go @@ -7,11 +7,12 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" "github.com/hashicorp/terraform-plugin-codegen-spec/datasource" "github.com/hashicorp/terraform-plugin-codegen-spec/resource" "github.com/hashicorp/terraform-plugin-codegen-spec/schema" + + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" ) func TestResourceBoolAttribute_Merge(t *testing.T) { @@ -113,7 +114,7 @@ func TestResourceBoolAttribute_Merge(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -155,7 +156,7 @@ func TestResourceBoolAttribute_ApplyOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -267,7 +268,7 @@ func TestDataSourceBoolAttribute_Merge(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -309,7 +310,7 @@ func TestDataSourceBoolAttribute_ApplyOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/attrmapper/data_source_attributes_test.go b/internal/mapper/attrmapper/data_source_attributes_test.go index 86942209..1535d9bd 100644 --- a/internal/mapper/attrmapper/data_source_attributes_test.go +++ b/internal/mapper/attrmapper/data_source_attributes_test.go @@ -7,10 +7,11 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" "github.com/hashicorp/terraform-plugin-codegen-spec/datasource" "github.com/hashicorp/terraform-plugin-codegen-spec/schema" + + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" ) func TestDataSourceAttributes_Merge(t *testing.T) { @@ -187,7 +188,7 @@ func TestDataSourceAttributes_Merge(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -355,7 +356,7 @@ func TestDataSourceAttributes_ApplyOverrides(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/attrmapper/float64_test.go b/internal/mapper/attrmapper/float64_test.go index 958dff4a..71e9bcd9 100644 --- a/internal/mapper/attrmapper/float64_test.go +++ b/internal/mapper/attrmapper/float64_test.go @@ -7,11 +7,12 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" "github.com/hashicorp/terraform-plugin-codegen-spec/datasource" "github.com/hashicorp/terraform-plugin-codegen-spec/resource" "github.com/hashicorp/terraform-plugin-codegen-spec/schema" + + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" ) func TestResourceFloat64Attribute_Merge(t *testing.T) { @@ -113,7 +114,7 @@ func TestResourceFloat64Attribute_Merge(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -155,7 +156,7 @@ func TestResourceFloat64Attribute_ApplyOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -267,7 +268,7 @@ func TestDataSourceFloat64Attribute_Merge(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -309,7 +310,7 @@ func TestDataSourceFloat64Attribute_ApplyOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/attrmapper/int64_test.go b/internal/mapper/attrmapper/int64_test.go index 28c67322..a3300447 100644 --- a/internal/mapper/attrmapper/int64_test.go +++ b/internal/mapper/attrmapper/int64_test.go @@ -7,11 +7,12 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" "github.com/hashicorp/terraform-plugin-codegen-spec/datasource" "github.com/hashicorp/terraform-plugin-codegen-spec/resource" "github.com/hashicorp/terraform-plugin-codegen-spec/schema" + + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" ) func TestResourceInt64Attribute_Merge(t *testing.T) { @@ -113,7 +114,7 @@ func TestResourceInt64Attribute_Merge(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -155,7 +156,7 @@ func TestResourceInt64Attribute_ApplyOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -267,7 +268,7 @@ func TestDataSourceInt64Attribute_Merge(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -309,7 +310,7 @@ func TestDataSourceInt64Attribute_ApplyOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/attrmapper/list_nested_test.go b/internal/mapper/attrmapper/list_nested_test.go index f457fee5..51dcf5d9 100644 --- a/internal/mapper/attrmapper/list_nested_test.go +++ b/internal/mapper/attrmapper/list_nested_test.go @@ -7,11 +7,12 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" "github.com/hashicorp/terraform-plugin-codegen-spec/datasource" "github.com/hashicorp/terraform-plugin-codegen-spec/resource" "github.com/hashicorp/terraform-plugin-codegen-spec/schema" + + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" ) func TestResourceListNestedAttribute_Merge(t *testing.T) { @@ -348,7 +349,7 @@ func TestResourceListNestedAttribute_Merge(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -410,7 +411,7 @@ func TestResourceListNestedAttribute_ApplyOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -559,7 +560,7 @@ func TestResourceListNestedAttribute_ApplyNestedOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -906,7 +907,7 @@ func TestDataSourceListNestedAttribute_Merge(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -968,7 +969,7 @@ func TestDataSourceListNestedAttribute_ApplyOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -1117,7 +1118,7 @@ func TestDataSourceListNestedAttribute_ApplyNestedOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/attrmapper/list_test.go b/internal/mapper/attrmapper/list_test.go index 63508261..515b8c18 100644 --- a/internal/mapper/attrmapper/list_test.go +++ b/internal/mapper/attrmapper/list_test.go @@ -7,11 +7,12 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" "github.com/hashicorp/terraform-plugin-codegen-spec/datasource" "github.com/hashicorp/terraform-plugin-codegen-spec/resource" "github.com/hashicorp/terraform-plugin-codegen-spec/schema" + + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" ) func TestResourceListAttribute_Merge(t *testing.T) { @@ -467,7 +468,7 @@ func TestResourceListAttribute_Merge(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -515,7 +516,7 @@ func TestResourceListAttribute_ApplyOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -981,7 +982,7 @@ func TestDataSourceListAttribute_Merge(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -1029,7 +1030,7 @@ func TestDataSourceListAttribute_ApplyOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/attrmapper/map_nested_test.go b/internal/mapper/attrmapper/map_nested_test.go index e25e4df0..b9fd8406 100644 --- a/internal/mapper/attrmapper/map_nested_test.go +++ b/internal/mapper/attrmapper/map_nested_test.go @@ -7,11 +7,12 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" "github.com/hashicorp/terraform-plugin-codegen-spec/datasource" "github.com/hashicorp/terraform-plugin-codegen-spec/resource" "github.com/hashicorp/terraform-plugin-codegen-spec/schema" + + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" ) func TestResourceMapNestedAttribute_Merge(t *testing.T) { @@ -348,7 +349,7 @@ func TestResourceMapNestedAttribute_Merge(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -410,7 +411,7 @@ func TestResourceMapNestedAttribute_ApplyOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -559,7 +560,7 @@ func TestResourceMapNestedAttribute_ApplyNestedOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -906,7 +907,7 @@ func TestDataSourceMapNestedAttribute_Merge(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -968,7 +969,7 @@ func TestDataSourceMapNestedAttribute_ApplyOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -1117,7 +1118,7 @@ func TestDataSourceMapNestedAttribute_ApplyNestedOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/attrmapper/map_test.go b/internal/mapper/attrmapper/map_test.go index e02f30db..35e7a0a3 100644 --- a/internal/mapper/attrmapper/map_test.go +++ b/internal/mapper/attrmapper/map_test.go @@ -7,11 +7,12 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" "github.com/hashicorp/terraform-plugin-codegen-spec/datasource" "github.com/hashicorp/terraform-plugin-codegen-spec/resource" "github.com/hashicorp/terraform-plugin-codegen-spec/schema" + + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" ) func TestResourceMapAttribute_Merge(t *testing.T) { @@ -467,7 +468,7 @@ func TestResourceMapAttribute_Merge(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -515,7 +516,7 @@ func TestResourceMapAttribute_ApplyOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -981,7 +982,7 @@ func TestDataSourceMapAttribute_Merge(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -1029,7 +1030,7 @@ func TestDataSourceMapAttribute_ApplyOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/attrmapper/number_test.go b/internal/mapper/attrmapper/number_test.go index 633a2352..295c69c2 100644 --- a/internal/mapper/attrmapper/number_test.go +++ b/internal/mapper/attrmapper/number_test.go @@ -7,11 +7,12 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" "github.com/hashicorp/terraform-plugin-codegen-spec/datasource" "github.com/hashicorp/terraform-plugin-codegen-spec/resource" "github.com/hashicorp/terraform-plugin-codegen-spec/schema" + + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" ) func TestResourceNumberAttribute_Merge(t *testing.T) { @@ -113,7 +114,7 @@ func TestResourceNumberAttribute_Merge(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -155,7 +156,7 @@ func TestResourceNumberAttribute_ApplyOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -267,7 +268,7 @@ func TestDataSourceNumberAttribute_Merge(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -309,7 +310,7 @@ func TestDataSourceNumberAttribute_ApplyOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/attrmapper/resource_attributes_test.go b/internal/mapper/attrmapper/resource_attributes_test.go index 51aa3311..45d0be90 100644 --- a/internal/mapper/attrmapper/resource_attributes_test.go +++ b/internal/mapper/attrmapper/resource_attributes_test.go @@ -7,10 +7,11 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" "github.com/hashicorp/terraform-plugin-codegen-spec/resource" "github.com/hashicorp/terraform-plugin-codegen-spec/schema" + + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" ) func TestResourceAttributes_Merge(t *testing.T) { @@ -187,7 +188,7 @@ func TestResourceAttributes_Merge(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -355,7 +356,7 @@ func TestResourceAttributes_ApplyOverrides(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/attrmapper/set_nested_test.go b/internal/mapper/attrmapper/set_nested_test.go index cd67f6a6..639a4f1c 100644 --- a/internal/mapper/attrmapper/set_nested_test.go +++ b/internal/mapper/attrmapper/set_nested_test.go @@ -7,11 +7,12 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" "github.com/hashicorp/terraform-plugin-codegen-spec/datasource" "github.com/hashicorp/terraform-plugin-codegen-spec/resource" "github.com/hashicorp/terraform-plugin-codegen-spec/schema" + + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" ) func TestResourceSetNestedAttribute_Merge(t *testing.T) { @@ -348,7 +349,7 @@ func TestResourceSetNestedAttribute_Merge(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -410,7 +411,7 @@ func TestResourceSetNestedAttribute_ApplyOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -559,7 +560,7 @@ func TestResourceSetNestedAttribute_ApplyNestedOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -906,7 +907,7 @@ func TestDataSourceSetNestedAttribute_Merge(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -968,7 +969,7 @@ func TestDataSourceSetNestedAttribute_ApplyOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -1117,7 +1118,7 @@ func TestDataSourceSetNestedAttribute_ApplyNestedOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/attrmapper/set_test.go b/internal/mapper/attrmapper/set_test.go index 06f5b962..f3dcbb75 100644 --- a/internal/mapper/attrmapper/set_test.go +++ b/internal/mapper/attrmapper/set_test.go @@ -7,11 +7,12 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" "github.com/hashicorp/terraform-plugin-codegen-spec/datasource" "github.com/hashicorp/terraform-plugin-codegen-spec/resource" "github.com/hashicorp/terraform-plugin-codegen-spec/schema" + + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" ) func TestResourceSetAttribute_Merge(t *testing.T) { @@ -467,7 +468,7 @@ func TestResourceSetAttribute_Merge(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -515,7 +516,7 @@ func TestResourceSetAttribute_ApplyOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -981,7 +982,7 @@ func TestDataSourceSetAttribute_Merge(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -1029,7 +1030,7 @@ func TestDataSourceSetAttribute_ApplyOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/attrmapper/single_nested_test.go b/internal/mapper/attrmapper/single_nested_test.go index e94fd0ff..3642fa88 100644 --- a/internal/mapper/attrmapper/single_nested_test.go +++ b/internal/mapper/attrmapper/single_nested_test.go @@ -7,11 +7,12 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" "github.com/hashicorp/terraform-plugin-codegen-spec/datasource" "github.com/hashicorp/terraform-plugin-codegen-spec/resource" "github.com/hashicorp/terraform-plugin-codegen-spec/schema" + + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" ) func TestResourceSingleNestedAttribute_Merge(t *testing.T) { @@ -314,7 +315,7 @@ func TestResourceSingleNestedAttribute_Merge(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -372,7 +373,7 @@ func TestResourceSingleNestedAttribute_ApplyOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -504,7 +505,7 @@ func TestResourceSingleNestedAttribute_ApplyNestedOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -817,7 +818,7 @@ func TestDataSourceSingleNestedAttribute_Merge(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -875,7 +876,7 @@ func TestDataSourceSingleNestedAttribute_ApplyOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -1007,7 +1008,7 @@ func TestDataSourceSingleNestedAttribute_ApplyNestedOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/attrmapper/string_test.go b/internal/mapper/attrmapper/string_test.go index 09d254af..6781f505 100644 --- a/internal/mapper/attrmapper/string_test.go +++ b/internal/mapper/attrmapper/string_test.go @@ -7,11 +7,12 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" "github.com/hashicorp/terraform-plugin-codegen-spec/datasource" "github.com/hashicorp/terraform-plugin-codegen-spec/resource" "github.com/hashicorp/terraform-plugin-codegen-spec/schema" + + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" ) func TestResourceStringAttribute_Merge(t *testing.T) { @@ -113,7 +114,7 @@ func TestResourceStringAttribute_Merge(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -155,7 +156,7 @@ func TestResourceStringAttribute_ApplyOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -267,7 +268,7 @@ func TestDataSourceStringAttribute_Merge(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -309,7 +310,7 @@ func TestDataSourceStringAttribute_ApplyOverride(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/datasource_mapper_test.go b/internal/mapper/datasource_mapper_test.go index 55c9a2df..e2edc84b 100644 --- a/internal/mapper/datasource_mapper_test.go +++ b/internal/mapper/datasource_mapper_test.go @@ -7,12 +7,13 @@ import ( "log/slog" "testing" + "github.com/hashicorp/terraform-plugin-codegen-spec/datasource" + "github.com/hashicorp/terraform-plugin-codegen-spec/schema" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/config" "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper" "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/util" - "github.com/hashicorp/terraform-plugin-codegen-spec/datasource" - "github.com/hashicorp/terraform-plugin-codegen-spec/schema" "github.com/google/go-cmp/cmp" "github.com/pb33f/libopenapi/datamodel/high/base" @@ -813,7 +814,7 @@ func TestDataSourceMapper_basic_merges(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() @@ -984,7 +985,7 @@ func TestDataSourceMapper_collections(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/frameworkvalidators/float64validator_test.go b/internal/mapper/frameworkvalidators/float64validator_test.go index 658ada04..126e8ac3 100644 --- a/internal/mapper/frameworkvalidators/float64validator_test.go +++ b/internal/mapper/frameworkvalidators/float64validator_test.go @@ -7,9 +7,10 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/frameworkvalidators" "github.com/hashicorp/terraform-plugin-codegen-spec/code" "github.com/hashicorp/terraform-plugin-codegen-spec/schema" + + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/frameworkvalidators" ) func TestFloat64ValidatorOneOf(t *testing.T) { @@ -52,7 +53,6 @@ func TestFloat64ValidatorOneOf(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/frameworkvalidators/int64validator_test.go b/internal/mapper/frameworkvalidators/int64validator_test.go index 6d04a69c..26c7cd9e 100644 --- a/internal/mapper/frameworkvalidators/int64validator_test.go +++ b/internal/mapper/frameworkvalidators/int64validator_test.go @@ -7,9 +7,10 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/frameworkvalidators" "github.com/hashicorp/terraform-plugin-codegen-spec/code" "github.com/hashicorp/terraform-plugin-codegen-spec/schema" + + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/frameworkvalidators" ) func TestInt64ValidatorAtLeast(t *testing.T) { @@ -33,7 +34,6 @@ func TestInt64ValidatorAtLeast(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -68,7 +68,6 @@ func TestInt64ValidatorAtMost(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -105,7 +104,6 @@ func TestInt64ValidatorBetween(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -159,7 +157,6 @@ func TestInt64ValidatorOneOf(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/frameworkvalidators/listvalidator_test.go b/internal/mapper/frameworkvalidators/listvalidator_test.go index dea94422..78ec71a5 100644 --- a/internal/mapper/frameworkvalidators/listvalidator_test.go +++ b/internal/mapper/frameworkvalidators/listvalidator_test.go @@ -7,9 +7,10 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/frameworkvalidators" "github.com/hashicorp/terraform-plugin-codegen-spec/code" "github.com/hashicorp/terraform-plugin-codegen-spec/schema" + + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/frameworkvalidators" ) func TestListValidatorSizeAtLeast(t *testing.T) { @@ -33,7 +34,6 @@ func TestListValidatorSizeAtLeast(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -68,7 +68,6 @@ func TestListValidatorSizeAtMost(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -105,7 +104,6 @@ func TestListValidatorSizeBetween(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -138,7 +136,6 @@ func TestListValidatorUniqueValues(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/frameworkvalidators/mapvalidator_test.go b/internal/mapper/frameworkvalidators/mapvalidator_test.go index 39082729..ee41b4bb 100644 --- a/internal/mapper/frameworkvalidators/mapvalidator_test.go +++ b/internal/mapper/frameworkvalidators/mapvalidator_test.go @@ -7,9 +7,10 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/frameworkvalidators" "github.com/hashicorp/terraform-plugin-codegen-spec/code" "github.com/hashicorp/terraform-plugin-codegen-spec/schema" + + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/frameworkvalidators" ) func TestMapValidatorSizeAtLeast(t *testing.T) { @@ -33,7 +34,6 @@ func TestMapValidatorSizeAtLeast(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -68,7 +68,6 @@ func TestMapValidatorSizeAtMost(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -105,7 +104,6 @@ func TestMapValidatorSizeBetween(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/frameworkvalidators/setvalidator_test.go b/internal/mapper/frameworkvalidators/setvalidator_test.go index 3874e8a3..af0e0976 100644 --- a/internal/mapper/frameworkvalidators/setvalidator_test.go +++ b/internal/mapper/frameworkvalidators/setvalidator_test.go @@ -7,9 +7,10 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/frameworkvalidators" "github.com/hashicorp/terraform-plugin-codegen-spec/code" "github.com/hashicorp/terraform-plugin-codegen-spec/schema" + + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/frameworkvalidators" ) func TestSetValidatorSizeAtLeast(t *testing.T) { @@ -33,7 +34,6 @@ func TestSetValidatorSizeAtLeast(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -68,7 +68,6 @@ func TestSetValidatorSizeAtMost(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -105,7 +104,6 @@ func TestSetValidatorSizeBetween(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/frameworkvalidators/stringvalidator_test.go b/internal/mapper/frameworkvalidators/stringvalidator_test.go index 9e877399..41c4089d 100644 --- a/internal/mapper/frameworkvalidators/stringvalidator_test.go +++ b/internal/mapper/frameworkvalidators/stringvalidator_test.go @@ -7,9 +7,10 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/frameworkvalidators" "github.com/hashicorp/terraform-plugin-codegen-spec/code" "github.com/hashicorp/terraform-plugin-codegen-spec/schema" + + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/frameworkvalidators" ) func TestStringValidatorLengthAtLeast(t *testing.T) { @@ -33,7 +34,6 @@ func TestStringValidatorLengthAtLeast(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -68,7 +68,6 @@ func TestStringValidatorLengthAtMost(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -105,7 +104,6 @@ func TestStringValidatorLengthBetween(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -159,7 +157,6 @@ func TestStringValidatorOneOf(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -229,7 +226,6 @@ func TestStringValidatorRegexMatches(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/oas/bool_test.go b/internal/mapper/oas/bool_test.go index 7904edcb..e99dfee2 100644 --- a/internal/mapper/oas/bool_test.go +++ b/internal/mapper/oas/bool_test.go @@ -6,14 +6,15 @@ package oas_test import ( "testing" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/oas" "github.com/hashicorp/terraform-plugin-codegen-spec/datasource" "github.com/hashicorp/terraform-plugin-codegen-spec/provider" "github.com/hashicorp/terraform-plugin-codegen-spec/resource" "github.com/hashicorp/terraform-plugin-codegen-spec/schema" "gopkg.in/yaml.v3" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/oas" + "github.com/google/go-cmp/cmp" "github.com/pb33f/libopenapi/datamodel/high/base" "github.com/pb33f/libopenapi/orderedmap" @@ -179,7 +180,6 @@ func TestBuildBoolResource(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -307,7 +307,6 @@ func TestBuildBoolDataSource(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -435,7 +434,6 @@ func TestBuildBoolProvider(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/oas/build_test.go b/internal/mapper/oas/build_test.go index 7736170e..de83bc31 100644 --- a/internal/mapper/oas/build_test.go +++ b/internal/mapper/oas/build_test.go @@ -7,11 +7,12 @@ import ( "regexp" "testing" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/oas" "github.com/hashicorp/terraform-plugin-codegen-spec/resource" "github.com/hashicorp/terraform-plugin-codegen-spec/schema" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/oas" + "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/pb33f/libopenapi/datamodel/high/base" @@ -110,7 +111,6 @@ func TestBuildSchemaFromRequest(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -168,7 +168,7 @@ func TestBuildSchemaFromRequest_Errors(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase + errRegex := regexp.MustCompile(testCase.expectedErrRegex) t.Run(name, func(t *testing.T) { @@ -320,7 +320,6 @@ func TestBuildSchemaFromResponse(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -450,7 +449,7 @@ func TestBuildSchemaFromResponse_Errors(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase + errRegex := regexp.MustCompile(testCase.expectedErrRegex) t.Run(name, func(t *testing.T) { @@ -945,7 +944,6 @@ func TestBuildSchema_MultiTypes(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -1070,7 +1068,6 @@ func TestBuildSchema_AllOfSchemaComposition(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -1188,7 +1185,7 @@ func TestBuildSchema_Errors(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase + errRegex := regexp.MustCompile(testCase.expectedErrRegex) t.Run(name, func(t *testing.T) { @@ -1264,7 +1261,6 @@ func TestBuildSchema_EdgeCases(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/oas/collection_test.go b/internal/mapper/oas/collection_test.go index f30d2970..66122492 100644 --- a/internal/mapper/oas/collection_test.go +++ b/internal/mapper/oas/collection_test.go @@ -6,14 +6,15 @@ package oas_test import ( "testing" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/oas" "github.com/hashicorp/terraform-plugin-codegen-spec/code" "github.com/hashicorp/terraform-plugin-codegen-spec/datasource" "github.com/hashicorp/terraform-plugin-codegen-spec/provider" "github.com/hashicorp/terraform-plugin-codegen-spec/resource" "github.com/hashicorp/terraform-plugin-codegen-spec/schema" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/oas" + "github.com/google/go-cmp/cmp" "github.com/pb33f/libopenapi/datamodel/high/base" "github.com/pb33f/libopenapi/orderedmap" @@ -666,7 +667,6 @@ func TestBuildCollectionResource(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -1329,7 +1329,6 @@ func TestBuildCollectionDataSource(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -1992,7 +1991,6 @@ func TestBuildCollectionProvider(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -2109,7 +2107,6 @@ func TestGetListValidators(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -2206,7 +2203,6 @@ func TestGetSetValidators(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/oas/integer_test.go b/internal/mapper/oas/integer_test.go index 4ed8df91..11ee720c 100644 --- a/internal/mapper/oas/integer_test.go +++ b/internal/mapper/oas/integer_test.go @@ -6,8 +6,6 @@ package oas_test import ( "testing" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/oas" "github.com/hashicorp/terraform-plugin-codegen-spec/code" "github.com/hashicorp/terraform-plugin-codegen-spec/datasource" "github.com/hashicorp/terraform-plugin-codegen-spec/provider" @@ -15,6 +13,9 @@ import ( "github.com/hashicorp/terraform-plugin-codegen-spec/schema" "gopkg.in/yaml.v3" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/oas" + "github.com/google/go-cmp/cmp" "github.com/pb33f/libopenapi/datamodel/high/base" "github.com/pb33f/libopenapi/orderedmap" @@ -215,7 +216,6 @@ func TestBuildIntegerResource(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -378,7 +378,6 @@ func TestBuildIntegerDataSource(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -541,7 +540,6 @@ func TestBuildIntegerProvider(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -661,7 +659,6 @@ func TestGetIntegerValidators(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/oas/map_test.go b/internal/mapper/oas/map_test.go index 493ba0fa..dc9776cb 100644 --- a/internal/mapper/oas/map_test.go +++ b/internal/mapper/oas/map_test.go @@ -7,8 +7,6 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/oas" "github.com/hashicorp/terraform-plugin-codegen-spec/code" "github.com/hashicorp/terraform-plugin-codegen-spec/datasource" "github.com/hashicorp/terraform-plugin-codegen-spec/provider" @@ -16,6 +14,9 @@ import ( "github.com/hashicorp/terraform-plugin-codegen-spec/schema" "github.com/pb33f/libopenapi/datamodel/high/base" "github.com/pb33f/libopenapi/orderedmap" + + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/oas" ) // TODO: add error tests @@ -260,7 +261,6 @@ func TestBuildMapResource(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -519,7 +519,6 @@ func TestBuildMapDataSource(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -778,7 +777,6 @@ func TestBuildMapProvider(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -875,7 +873,6 @@ func TestGetMapValidators(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/oas/number_test.go b/internal/mapper/oas/number_test.go index d3411769..2b70a56f 100644 --- a/internal/mapper/oas/number_test.go +++ b/internal/mapper/oas/number_test.go @@ -6,8 +6,6 @@ package oas_test import ( "testing" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/oas" "github.com/hashicorp/terraform-plugin-codegen-spec/code" "github.com/hashicorp/terraform-plugin-codegen-spec/datasource" "github.com/hashicorp/terraform-plugin-codegen-spec/provider" @@ -15,6 +13,9 @@ import ( "github.com/hashicorp/terraform-plugin-codegen-spec/schema" "gopkg.in/yaml.v3" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/oas" + "github.com/google/go-cmp/cmp" "github.com/pb33f/libopenapi/datamodel/high/base" "github.com/pb33f/libopenapi/orderedmap" @@ -388,7 +389,6 @@ func TestBuildNumberResource(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -721,7 +721,6 @@ func TestBuildNumberDataSource(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -1054,7 +1053,6 @@ func TestBuildNumberProvider(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -1113,7 +1111,6 @@ func TestGetFloatValidators(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/oas/oas_schema_test.go b/internal/mapper/oas/oas_schema_test.go index dc888fdf..e8e99551 100644 --- a/internal/mapper/oas/oas_schema_test.go +++ b/internal/mapper/oas/oas_schema_test.go @@ -7,8 +7,9 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/oas" "github.com/pb33f/libopenapi/datamodel/high/base" + + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/oas" ) func pointer[T any](value T) *T { @@ -71,7 +72,6 @@ func TestOASSchemaGetDeprecationMessage(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -115,7 +115,6 @@ func TestGetDescription_Override(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -172,7 +171,6 @@ func TestIsPropertyIgnored(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -237,7 +235,6 @@ func TestGetIgnoresForNested(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/oas/single_nested_test.go b/internal/mapper/oas/single_nested_test.go index 8070b40c..b1063313 100644 --- a/internal/mapper/oas/single_nested_test.go +++ b/internal/mapper/oas/single_nested_test.go @@ -6,13 +6,14 @@ package oas_test import ( "testing" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/oas" "github.com/hashicorp/terraform-plugin-codegen-spec/datasource" "github.com/hashicorp/terraform-plugin-codegen-spec/provider" "github.com/hashicorp/terraform-plugin-codegen-spec/resource" "github.com/hashicorp/terraform-plugin-codegen-spec/schema" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/oas" + "github.com/google/go-cmp/cmp" "github.com/pb33f/libopenapi/datamodel/high/base" "github.com/pb33f/libopenapi/orderedmap" @@ -130,7 +131,6 @@ func TestBuildSingleNestedResource(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -258,7 +258,6 @@ func TestBuildSingleNestedDataSource(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -386,7 +385,6 @@ func TestBuildSingleNestedProvider(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/oas/string_test.go b/internal/mapper/oas/string_test.go index 7d72b975..0d2df4cf 100644 --- a/internal/mapper/oas/string_test.go +++ b/internal/mapper/oas/string_test.go @@ -6,8 +6,6 @@ package oas_test import ( "testing" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/oas" "github.com/hashicorp/terraform-plugin-codegen-spec/code" "github.com/hashicorp/terraform-plugin-codegen-spec/datasource" "github.com/hashicorp/terraform-plugin-codegen-spec/provider" @@ -15,6 +13,9 @@ import ( "github.com/hashicorp/terraform-plugin-codegen-spec/schema" "gopkg.in/yaml.v3" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/attrmapper" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/oas" + "github.com/google/go-cmp/cmp" "github.com/pb33f/libopenapi/datamodel/high/base" "github.com/pb33f/libopenapi/orderedmap" @@ -217,7 +218,6 @@ func TestBuildStringResource(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -382,7 +382,6 @@ func TestBuildStringDataSource(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -547,7 +546,6 @@ func TestBuildStringProvider(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() @@ -690,7 +688,6 @@ func TestGetStringValidators(t *testing.T) { } for name, testCase := range testCases { - name, testCase := name, testCase t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/provider_mapper_test.go b/internal/mapper/provider_mapper_test.go index bd90c021..8b030372 100644 --- a/internal/mapper/provider_mapper_test.go +++ b/internal/mapper/provider_mapper_test.go @@ -8,14 +8,15 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/config" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper" - "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/util" "github.com/hashicorp/terraform-plugin-codegen-spec/provider" "github.com/hashicorp/terraform-plugin-codegen-spec/schema" "github.com/pb33f/libopenapi/datamodel/high/base" "github.com/pb33f/libopenapi/orderedmap" + + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/config" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/util" ) func TestProviderMapper_basic(t *testing.T) { @@ -245,7 +246,7 @@ func TestProviderMapper_basic(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/resource_mapper_test.go b/internal/mapper/resource_mapper_test.go index 09cc42b2..6608873b 100644 --- a/internal/mapper/resource_mapper_test.go +++ b/internal/mapper/resource_mapper_test.go @@ -7,12 +7,13 @@ import ( "log/slog" "testing" + "github.com/hashicorp/terraform-plugin-codegen-spec/resource" + "github.com/hashicorp/terraform-plugin-codegen-spec/schema" + "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/config" "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/explorer" "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper" "github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/util" - "github.com/hashicorp/terraform-plugin-codegen-spec/resource" - "github.com/hashicorp/terraform-plugin-codegen-spec/schema" "github.com/google/go-cmp/cmp" "github.com/pb33f/libopenapi/datamodel/high/base" @@ -1037,7 +1038,7 @@ func TestResourceMapper_basic_merges(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/mapper/util/framework_identifier_test.go b/internal/mapper/util/framework_identifier_test.go index fe556b14..35dc031e 100644 --- a/internal/mapper/util/framework_identifier_test.go +++ b/internal/mapper/util/framework_identifier_test.go @@ -90,7 +90,7 @@ func TestFrameworkIdentifier(t *testing.T) { }, } for name, testCase := range testCases { - name, testCase := name, testCase + t.Run(name, func(t *testing.T) { t.Parallel()