replace remaining types in tests

This commit is contained in:
James Bardin
2023-07-06 10:22:57 -04:00
parent 4e8dd5866c
commit 36d34135ad
11 changed files with 133 additions and 96 deletions

View File

@@ -6987,13 +6987,17 @@ func runTestCases(t *testing.T, testCases map[string]testCase) {
}
tfschemas := &terraform.Schemas{
Providers: map[addrs.Provider]*providers.Schemas{
Providers: map[addrs.Provider]providers.Schemas{
src.ProviderAddr.Provider: {
ResourceTypes: map[string]*configschema.Block{
src.Addr.Resource.Resource.Type: tc.Schema,
ResourceTypes: map[string]providers.Schema{
src.Addr.Resource.Resource.Type: {
Block: tc.Schema,
},
},
DataSources: map[string]*configschema.Block{
src.Addr.Resource.Resource.Type: tc.Schema,
DataSources: map[string]providers.Schema{
src.Addr.Resource.Resource.Type: {
Block: tc.Schema,
},
},
},
},

View File

@@ -156,8 +156,8 @@ func testProviderSchema() *providers.GetProviderSchemaResponse {
func testSchemas() *terraform.Schemas {
provider := testProvider()
return &terraform.Schemas{
Providers: map[addrs.Provider]*terraform.ProviderSchema{
addrs.NewDefaultProvider("test"): provider.ProviderSchema(),
Providers: map[addrs.Provider]providers.Schemas{
addrs.NewDefaultProvider("test"): provider.GetProviderSchema(),
},
}
}

View File

@@ -11,6 +11,7 @@ import (
"github.com/hashicorp/terraform/internal/addrs"
"github.com/hashicorp/terraform/internal/configs/configschema"
"github.com/hashicorp/terraform/internal/plans"
"github.com/hashicorp/terraform/internal/providers"
"github.com/hashicorp/terraform/internal/terraform"
"github.com/zclconf/go-cty/cty"
)
@@ -344,19 +345,19 @@ func TestMarshalPlanValuesNoopDeposed(t *testing.T) {
func testSchemas() *terraform.Schemas {
return &terraform.Schemas{
Providers: map[addrs.Provider]*terraform.ProviderSchema{
addrs.NewDefaultProvider("test"): &terraform.ProviderSchema{
ResourceTypes: map[string]*configschema.Block{
Providers: map[addrs.Provider]providers.Schemas{
addrs.NewDefaultProvider("test"): providers.Schemas{
ResourceTypes: map[string]providers.Schema{
"test_thing": {
Attributes: map[string]*configschema.Attribute{
"woozles": {Type: cty.String, Optional: true, Computed: true},
"foozles": {Type: cty.String, Optional: true},
Version: 1,
Block: &configschema.Block{
Attributes: map[string]*configschema.Attribute{
"woozles": {Type: cty.String, Optional: true, Computed: true},
"foozles": {Type: cty.String, Optional: true},
},
},
},
},
ResourceTypeSchemaVersions: map[string]uint64{
"test_thing": 1,
},
},
},
}

View File

@@ -14,6 +14,7 @@ import (
"github.com/hashicorp/terraform/internal/addrs"
"github.com/hashicorp/terraform/internal/configs/configschema"
"github.com/hashicorp/terraform/internal/lang/marks"
"github.com/hashicorp/terraform/internal/providers"
"github.com/hashicorp/terraform/internal/states"
"github.com/hashicorp/terraform/internal/terraform"
)
@@ -807,25 +808,31 @@ func TestMarshalModules_parent_no_resources(t *testing.T) {
func testSchemas() *terraform.Schemas {
return &terraform.Schemas{
Providers: map[addrs.Provider]*terraform.ProviderSchema{
Providers: map[addrs.Provider]providers.Schemas{
addrs.NewDefaultProvider("test"): {
ResourceTypes: map[string]*configschema.Block{
ResourceTypes: map[string]providers.Schema{
"test_thing": {
Attributes: map[string]*configschema.Attribute{
"woozles": {Type: cty.String, Optional: true, Computed: true},
"foozles": {Type: cty.String, Optional: true, Sensitive: true},
Block: &configschema.Block{
Attributes: map[string]*configschema.Attribute{
"woozles": {Type: cty.String, Optional: true, Computed: true},
"foozles": {Type: cty.String, Optional: true, Sensitive: true},
},
},
},
"test_instance": {
Attributes: map[string]*configschema.Attribute{
"id": {Type: cty.String, Optional: true, Computed: true},
"foo": {Type: cty.String, Optional: true},
"bar": {Type: cty.String, Optional: true},
Block: &configschema.Block{
Attributes: map[string]*configschema.Attribute{
"id": {Type: cty.String, Optional: true, Computed: true},
"foo": {Type: cty.String, Optional: true},
"bar": {Type: cty.String, Optional: true},
},
},
},
"test_map_attr": {
Attributes: map[string]*configschema.Attribute{
"data": {Type: cty.Map(cty.String), Optional: true, Computed: true, Sensitive: true},
Block: &configschema.Block{
Attributes: map[string]*configschema.Attribute{
"data": {Type: cty.Map(cty.String), Optional: true, Computed: true, Sensitive: true},
},
},
},
},

View File

@@ -133,8 +133,8 @@ func testPlanWithDatasource(t *testing.T) *plans.Plan {
func testSchemas() *terraform.Schemas {
provider := testProvider()
return &terraform.Schemas{
Providers: map[addrs.Provider]*terraform.ProviderSchema{
addrs.NewDefaultProvider("test"): provider.ProviderSchema(),
Providers: map[addrs.Provider]providers.Schemas{
addrs.NewDefaultProvider("test"): provider.GetProviderSchema(),
},
}
}

View File

@@ -13,6 +13,7 @@ import (
"github.com/hashicorp/terraform/internal/configs/configschema"
"github.com/hashicorp/terraform/internal/initwd"
"github.com/hashicorp/terraform/internal/plans"
"github.com/hashicorp/terraform/internal/providers"
"github.com/hashicorp/terraform/internal/states"
"github.com/hashicorp/terraform/internal/states/statefile"
"github.com/hashicorp/terraform/internal/terminal"
@@ -130,13 +131,15 @@ func TestShowJSON(t *testing.T) {
v := NewShow(arguments.ViewJSON, view)
schemas := &terraform.Schemas{
Providers: map[addrs.Provider]*terraform.ProviderSchema{
Providers: map[addrs.Provider]providers.Schemas{
addrs.NewDefaultProvider("test"): {
ResourceTypes: map[string]*configschema.Block{
ResourceTypes: map[string]providers.Schema{
"test_resource": {
Attributes: map[string]*configschema.Attribute{
"id": {Type: cty.String, Optional: true, Computed: true},
"foo": {Type: cty.String, Optional: true},
Block: &configschema.Block{
Attributes: map[string]*configschema.Attribute{
"id": {Type: cty.String, Optional: true, Computed: true},
"foo": {Type: cty.String, Optional: true},
},
},
},
},