From efba6314bc806a220134cdd183faac0e758007aa Mon Sep 17 00:00:00 2001 From: Baraa Basata Date: Wed, 26 Feb 2025 07:40:02 -0500 Subject: [PATCH 01/11] Being moving one test to use ProtoV6ProviderFactories --- statecheck/expect_known_value_test.go | 10 +++-- statecheck/test_provider.go | 0 statecheck/test_provider_test.go | 45 +++++++++++++++++++++ statecheck/test_resource.go | 1 + statecheck/test_resource_test.go | 58 +++++++++++++++++++++++++++ 5 files changed, 110 insertions(+), 4 deletions(-) create mode 100644 statecheck/test_provider.go create mode 100644 statecheck/test_provider_test.go create mode 100644 statecheck/test_resource.go create mode 100644 statecheck/test_resource_test.go diff --git a/statecheck/expect_known_value_test.go b/statecheck/expect_known_value_test.go index 2eb56d4e4..1940827b4 100644 --- a/statecheck/expect_known_value_test.go +++ b/statecheck/expect_known_value_test.go @@ -13,10 +13,12 @@ import ( "github.com/google/go-cmp/cmp" tfjson "github.com/hashicorp/terraform-json" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" r "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/providerserver" "github.com/hashicorp/terraform-plugin-testing/knownvalue" "github.com/hashicorp/terraform-plugin-testing/statecheck" "github.com/hashicorp/terraform-plugin-testing/tfjsonpath" @@ -197,11 +199,11 @@ func TestExpectKnownValue_CheckState_AttributeValueNotNull(t *testing.T) { func TestExpectKnownValue_CheckState_Bool(t *testing.T) { t.Parallel() + p := aTestProvider{} + r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(p), }, Steps: []r.TestStep{ { diff --git a/statecheck/test_provider.go b/statecheck/test_provider.go new file mode 100644 index 000000000..e69de29bb diff --git a/statecheck/test_provider_test.go b/statecheck/test_provider_test.go new file mode 100644 index 000000000..b5cd8fb71 --- /dev/null +++ b/statecheck/test_provider_test.go @@ -0,0 +1,45 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package statecheck_test + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/datasource" + "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/provider" + "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/resource" +) + +type aTestProvider struct { +} + +func (t aTestProvider) Configure(ctx context.Context, request provider.ConfigureRequest, response *provider.ConfigureResponse) { + //TODO implement me + panic("implement me") +} + +func (t aTestProvider) DataSourcesMap() map[string]datasource.DataSource { + //TODO implement me + panic("implement me") +} + +func (t aTestProvider) ResourcesMap() map[string]resource.Resource { + //TODO implement me + panic("implement me") +} + +func (t aTestProvider) Schema(ctx context.Context, request provider.SchemaRequest, response *provider.SchemaResponse) { + //TODO implement me + panic("implement me") +} + +func (t aTestProvider) Stop(ctx context.Context, request provider.StopRequest, response *provider.StopResponse) { + //TODO implement me + panic("implement me") +} + +func (t aTestProvider) ValidateConfig(ctx context.Context, request provider.ValidateConfigRequest, response *provider.ValidateConfigResponse) { + //TODO implement me + panic("implement me") +} diff --git a/statecheck/test_resource.go b/statecheck/test_resource.go new file mode 100644 index 000000000..2728844c9 --- /dev/null +++ b/statecheck/test_resource.go @@ -0,0 +1 @@ +package statecheck diff --git a/statecheck/test_resource_test.go b/statecheck/test_resource_test.go new file mode 100644 index 000000000..560c38513 --- /dev/null +++ b/statecheck/test_resource_test.go @@ -0,0 +1,58 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package statecheck_test + +import ( + "context" + "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/resource" +) + +type testResource struct {} + +func (t testResource) Create(ctx context.Context, request resource.CreateRequest, response *resource.CreateResponse) { + //TODO implement me + panic("implement me") +} + +func (t testResource) Delete(ctx context.Context, request resource.DeleteRequest, response *resource.DeleteResponse) { + //TODO implement me + panic("implement me") +} + +func (t testResource) ImportState(ctx context.Context, request resource.ImportStateRequest, response *resource.ImportStateResponse) { + //TODO implement me + panic("implement me") +} + +func (t testResource) PlanChange(ctx context.Context, request resource.PlanChangeRequest, response *resource.PlanChangeResponse) { + //TODO implement me + panic("implement me") +} + +func (t testResource) Read(ctx context.Context, request resource.ReadRequest, response *resource.ReadResponse) { + //TODO implement me + panic("implement me") +} + +func (t testResource) Schema(ctx context.Context, request resource.SchemaRequest, response *resource.SchemaResponse) { + //TODO implement me + panic("implement me") +} + +func (t testResource) Update(ctx context.Context, request resource.UpdateRequest, response *resource.UpdateResponse) { + //TODO implement me + panic("implement me") +} + +func (t testResource) UpgradeState(ctx context.Context, request resource.UpgradeStateRequest, response *resource.UpgradeStateResponse) { + //TODO implement me + panic("implement me") +} + +func (t testResource) ValidateConfig(ctx context.Context, request resource.ValidateConfigRequest, response *resource.ValidateConfigResponse) { + //TODO implement me + panic("implement me") +} + + From ae8070fe7c92b4e580dca54e0063e8d75d8c462a Mon Sep 17 00:00:00 2001 From: Baraa Basata Date: Wed, 26 Feb 2025 07:55:46 -0500 Subject: [PATCH 02/11] red, but better --- statecheck/test_provider_test.go | 27 ++++++++++++-------- statecheck/test_resource.go | 1 - statecheck/test_resource_test.go | 43 ++++++++++++++++++++------------ 3 files changed, 44 insertions(+), 27 deletions(-) delete mode 100644 statecheck/test_resource.go diff --git a/statecheck/test_provider_test.go b/statecheck/test_provider_test.go index b5cd8fb71..8c2306e81 100644 --- a/statecheck/test_provider_test.go +++ b/statecheck/test_provider_test.go @@ -6,6 +6,8 @@ package statecheck_test import ( "context" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-go/tftypes" "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/datasource" "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/provider" "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/resource" @@ -15,23 +17,30 @@ type aTestProvider struct { } func (t aTestProvider) Configure(ctx context.Context, request provider.ConfigureRequest, response *provider.ConfigureResponse) { - //TODO implement me - panic("implement me") } func (t aTestProvider) DataSourcesMap() map[string]datasource.DataSource { - //TODO implement me - panic("implement me") + return nil } func (t aTestProvider) ResourcesMap() map[string]resource.Resource { - //TODO implement me - panic("implement me") + return map[string]resource.Resource{ + "test_resource": &aTestResource{}, + } } func (t aTestProvider) Schema(ctx context.Context, request provider.SchemaRequest, response *provider.SchemaResponse) { - //TODO implement me - panic("implement me") + schema := tfprotov6.Schema{ + Block: &tfprotov6.SchemaBlock{ + Attributes: []*tfprotov6.SchemaAttribute{ + { + Name: "planet", + Type: tftypes.String, + }, + }, + }, + } + response.Schema = &schema } func (t aTestProvider) Stop(ctx context.Context, request provider.StopRequest, response *provider.StopResponse) { @@ -40,6 +49,4 @@ func (t aTestProvider) Stop(ctx context.Context, request provider.StopRequest, r } func (t aTestProvider) ValidateConfig(ctx context.Context, request provider.ValidateConfigRequest, response *provider.ValidateConfigResponse) { - //TODO implement me - panic("implement me") } diff --git a/statecheck/test_resource.go b/statecheck/test_resource.go deleted file mode 100644 index 2728844c9..000000000 --- a/statecheck/test_resource.go +++ /dev/null @@ -1 +0,0 @@ -package statecheck diff --git a/statecheck/test_resource_test.go b/statecheck/test_resource_test.go index 560c38513..1079f435f 100644 --- a/statecheck/test_resource_test.go +++ b/statecheck/test_resource_test.go @@ -5,54 +5,65 @@ package statecheck_test import ( "context" + + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-go/tftypes" "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/resource" ) -type testResource struct {} +type aTestResource struct{} -func (t testResource) Create(ctx context.Context, request resource.CreateRequest, response *resource.CreateResponse) { +func (t aTestResource) Create(ctx context.Context, request resource.CreateRequest, response *resource.CreateResponse) { //TODO implement me panic("implement me") } -func (t testResource) Delete(ctx context.Context, request resource.DeleteRequest, response *resource.DeleteResponse) { +func (t aTestResource) Delete(ctx context.Context, request resource.DeleteRequest, response *resource.DeleteResponse) { //TODO implement me panic("implement me") } -func (t testResource) ImportState(ctx context.Context, request resource.ImportStateRequest, response *resource.ImportStateResponse) { +func (t aTestResource) ImportState(ctx context.Context, request resource.ImportStateRequest, response *resource.ImportStateResponse) { //TODO implement me panic("implement me") } -func (t testResource) PlanChange(ctx context.Context, request resource.PlanChangeRequest, response *resource.PlanChangeResponse) { +func (t aTestResource) PlanChange(ctx context.Context, request resource.PlanChangeRequest, response *resource.PlanChangeResponse) { //TODO implement me panic("implement me") } -func (t testResource) Read(ctx context.Context, request resource.ReadRequest, response *resource.ReadResponse) { +func (t aTestResource) Read(ctx context.Context, request resource.ReadRequest, response *resource.ReadResponse) { //TODO implement me panic("implement me") } -func (t testResource) Schema(ctx context.Context, request resource.SchemaRequest, response *resource.SchemaResponse) { - //TODO implement me - panic("implement me") +func (t aTestResource) Schema(ctx context.Context, request resource.SchemaRequest, response *resource.SchemaResponse) { + schema := tfprotov6.Schema{ + Block: &tfprotov6.SchemaBlock{ + Attributes: []*tfprotov6.SchemaAttribute{ + { + Name: "bool_attribute", + Type: tftypes.Bool, + Computed: true, + }, + }, + Description: "", + DescriptionKind: 0, + }, + } + response.Schema = &schema } -func (t testResource) Update(ctx context.Context, request resource.UpdateRequest, response *resource.UpdateResponse) { +func (t aTestResource) Update(ctx context.Context, request resource.UpdateRequest, response *resource.UpdateResponse) { //TODO implement me panic("implement me") } -func (t testResource) UpgradeState(ctx context.Context, request resource.UpgradeStateRequest, response *resource.UpgradeStateResponse) { +func (t aTestResource) UpgradeState(ctx context.Context, request resource.UpgradeStateRequest, response *resource.UpgradeStateResponse) { //TODO implement me panic("implement me") } -func (t testResource) ValidateConfig(ctx context.Context, request resource.ValidateConfigRequest, response *resource.ValidateConfigResponse) { - //TODO implement me - panic("implement me") +func (t aTestResource) ValidateConfig(ctx context.Context, request resource.ValidateConfigRequest, response *resource.ValidateConfigResponse) { } - - From b495347fd576fca9fd0196cb8ba5c886cc20298b Mon Sep 17 00:00:00 2001 From: Baraa Basata Date: Wed, 26 Feb 2025 08:18:14 -0500 Subject: [PATCH 03/11] green --- statecheck/expect_known_value_test.go | 4 +- statecheck/test_provider.go | 0 statecheck/test_provider_test.go | 53 +++++++------------- statecheck/test_resource_test.go | 69 --------------------------- 4 files changed, 17 insertions(+), 109 deletions(-) delete mode 100644 statecheck/test_provider.go delete mode 100644 statecheck/test_resource_test.go diff --git a/statecheck/expect_known_value_test.go b/statecheck/expect_known_value_test.go index 1940827b4..eb93ee435 100644 --- a/statecheck/expect_known_value_test.go +++ b/statecheck/expect_known_value_test.go @@ -199,11 +199,9 @@ func TestExpectKnownValue_CheckState_AttributeValueNotNull(t *testing.T) { func TestExpectKnownValue_CheckState_Bool(t *testing.T) { t.Parallel() - p := aTestProvider{} - r.Test(t, r.TestCase{ ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ - "test": providerserver.NewProviderServer(p), + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { diff --git a/statecheck/test_provider.go b/statecheck/test_provider.go deleted file mode 100644 index e69de29bb..000000000 diff --git a/statecheck/test_provider_test.go b/statecheck/test_provider_test.go index 8c2306e81..294c44e48 100644 --- a/statecheck/test_provider_test.go +++ b/statecheck/test_provider_test.go @@ -4,49 +4,28 @@ package statecheck_test import ( - "context" - "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-go/tftypes" - "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/datasource" - "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/provider" + "github.com/hashicorp/terraform-plugin-testing/internal/testing/testprovider" "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/resource" ) -type aTestProvider struct { -} - -func (t aTestProvider) Configure(ctx context.Context, request provider.ConfigureRequest, response *provider.ConfigureResponse) { -} - -func (t aTestProvider) DataSourcesMap() map[string]datasource.DataSource { - return nil -} - -func (t aTestProvider) ResourcesMap() map[string]resource.Resource { - return map[string]resource.Resource{ - "test_resource": &aTestResource{}, - } -} - -func (t aTestProvider) Schema(ctx context.Context, request provider.SchemaRequest, response *provider.SchemaResponse) { - schema := tfprotov6.Schema{ - Block: &tfprotov6.SchemaBlock{ - Attributes: []*tfprotov6.SchemaAttribute{ - { - Name: "planet", - Type: tftypes.String, +var anTestProvider = testprovider.Provider{ + Resources: map[string]testprovider.Resource{ + "test_resource": { + SchemaResponse: &resource.SchemaResponse{ + Schema: &tfprotov6.Schema{ + Block: &tfprotov6.SchemaBlock{ + Attributes: []*tfprotov6.SchemaAttribute{ + { + Name: "bool_attribute", + Type: tftypes.Bool, + Computed: true, + }, + }, + }, }, }, }, - } - response.Schema = &schema -} - -func (t aTestProvider) Stop(ctx context.Context, request provider.StopRequest, response *provider.StopResponse) { - //TODO implement me - panic("implement me") -} - -func (t aTestProvider) ValidateConfig(ctx context.Context, request provider.ValidateConfigRequest, response *provider.ValidateConfigResponse) { + }, } diff --git a/statecheck/test_resource_test.go b/statecheck/test_resource_test.go deleted file mode 100644 index 1079f435f..000000000 --- a/statecheck/test_resource_test.go +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package statecheck_test - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-go/tfprotov6" - "github.com/hashicorp/terraform-plugin-go/tftypes" - "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/resource" -) - -type aTestResource struct{} - -func (t aTestResource) Create(ctx context.Context, request resource.CreateRequest, response *resource.CreateResponse) { - //TODO implement me - panic("implement me") -} - -func (t aTestResource) Delete(ctx context.Context, request resource.DeleteRequest, response *resource.DeleteResponse) { - //TODO implement me - panic("implement me") -} - -func (t aTestResource) ImportState(ctx context.Context, request resource.ImportStateRequest, response *resource.ImportStateResponse) { - //TODO implement me - panic("implement me") -} - -func (t aTestResource) PlanChange(ctx context.Context, request resource.PlanChangeRequest, response *resource.PlanChangeResponse) { - //TODO implement me - panic("implement me") -} - -func (t aTestResource) Read(ctx context.Context, request resource.ReadRequest, response *resource.ReadResponse) { - //TODO implement me - panic("implement me") -} - -func (t aTestResource) Schema(ctx context.Context, request resource.SchemaRequest, response *resource.SchemaResponse) { - schema := tfprotov6.Schema{ - Block: &tfprotov6.SchemaBlock{ - Attributes: []*tfprotov6.SchemaAttribute{ - { - Name: "bool_attribute", - Type: tftypes.Bool, - Computed: true, - }, - }, - Description: "", - DescriptionKind: 0, - }, - } - response.Schema = &schema -} - -func (t aTestResource) Update(ctx context.Context, request resource.UpdateRequest, response *resource.UpdateResponse) { - //TODO implement me - panic("implement me") -} - -func (t aTestResource) UpgradeState(ctx context.Context, request resource.UpgradeStateRequest, response *resource.UpgradeStateResponse) { - //TODO implement me - panic("implement me") -} - -func (t aTestResource) ValidateConfig(ctx context.Context, request resource.ValidateConfigRequest, response *resource.ValidateConfigResponse) { -} From b7eac0bdbd1c461920c537c02877bccc0b790c91 Mon Sep 17 00:00:00 2001 From: Baraa Basata Date: Wed, 26 Feb 2025 08:25:21 -0500 Subject: [PATCH 04/11] more green --- statecheck/expect_known_value_test.go | 42 +++++++++------------------ statecheck/test_provider_test.go | 12 +++++++- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/statecheck/expect_known_value_test.go b/statecheck/expect_known_value_test.go index eb93ee435..7eced141c 100644 --- a/statecheck/expect_known_value_test.go +++ b/statecheck/expect_known_value_test.go @@ -225,10 +225,8 @@ func TestExpectKnownValue_CheckState_Bool_KnownValueWrongType(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -253,10 +251,8 @@ func TestExpectKnownValue_CheckState_Bool_KnownValueWrongValue(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -281,10 +277,8 @@ func TestExpectKnownValue_CheckState_Float64(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -309,10 +303,8 @@ func TestExpectKnownValue_CheckState_Float64_KnownValueWrongType(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -337,10 +329,8 @@ func TestExpectKnownValue_CheckState_Float64_KnownValueWrongValue(t *testing.T) t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -365,10 +355,8 @@ func TestExpectKnownValue_CheckState_Int64(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -392,10 +380,8 @@ func TestExpectKnownValue_CheckState_Int64_KnownValueWrongValue(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { diff --git a/statecheck/test_provider_test.go b/statecheck/test_provider_test.go index 294c44e48..3bc4641d9 100644 --- a/statecheck/test_provider_test.go +++ b/statecheck/test_provider_test.go @@ -20,7 +20,17 @@ var anTestProvider = testprovider.Provider{ { Name: "bool_attribute", Type: tftypes.Bool, - Computed: true, + Optional: true, + }, + { + Name: "float_attribute", + Type: tftypes.Number, + Optional: true, + }, + { + Name: "int_attribute", + Type: tftypes.Number, + Optional: true, }, }, }, From 8cbbe5b76d4a8624ea8797abf72f9d0e909fcb32 Mon Sep 17 00:00:00 2001 From: Baraa Basata Date: Wed, 26 Feb 2025 08:25:21 -0500 Subject: [PATCH 05/11] more green --- statecheck/expect_known_value_test.go | 24 ++++++++---------------- statecheck/test_provider_test.go | 10 ++++++++++ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/statecheck/expect_known_value_test.go b/statecheck/expect_known_value_test.go index 7eced141c..159dba47e 100644 --- a/statecheck/expect_known_value_test.go +++ b/statecheck/expect_known_value_test.go @@ -1338,10 +1338,8 @@ func TestExpectKnownValue_CheckState_String(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1364,10 +1362,8 @@ func TestExpectKnownValue_CheckState_String_Custom(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1420,10 +1416,8 @@ func TestExpectKnownValue_CheckState_String_KnownValueWrongType(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1447,10 +1441,8 @@ func TestExpectKnownValue_CheckState_String_KnownValueWrongValue(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { diff --git a/statecheck/test_provider_test.go b/statecheck/test_provider_test.go index 3bc4641d9..c36b5eca7 100644 --- a/statecheck/test_provider_test.go +++ b/statecheck/test_provider_test.go @@ -32,6 +32,16 @@ var anTestProvider = testprovider.Provider{ Type: tftypes.Number, Optional: true, }, + { + Name: "string_attribute", + Type: tftypes.String, + Optional: true, + }, + { + Name: "string_computed_attribute", + Type: tftypes.String, + Computed: true, + }, }, }, }, From 62fe008614f8160a2e940109f8a228cad3b6511e Mon Sep 17 00:00:00 2001 From: Baraa Basata Date: Wed, 26 Feb 2025 08:25:21 -0500 Subject: [PATCH 06/11] more green --- statecheck/expect_known_value_test.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/statecheck/expect_known_value_test.go b/statecheck/expect_known_value_test.go index 159dba47e..4750bfcf2 100644 --- a/statecheck/expect_known_value_test.go +++ b/statecheck/expect_known_value_test.go @@ -969,10 +969,8 @@ func TestExpectKnownValue_CheckState_Number(t *testing.T) { } r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1002,10 +1000,8 @@ func TestExpectKnownValue_CheckState_Number_KnownValueWrongValue(t *testing.T) { } r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { From 426171c778622b3768691db7af305af0432cac0d Mon Sep 17 00:00:00 2001 From: Baraa Basata Date: Wed, 26 Feb 2025 08:25:21 -0500 Subject: [PATCH 07/11] more green --- statecheck/expect_known_value_test.go | 45 +++++++++++++-------------- statecheck/test_provider_test.go | 5 +++ 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/statecheck/expect_known_value_test.go b/statecheck/expect_known_value_test.go index 4750bfcf2..f553ad423 100644 --- a/statecheck/expect_known_value_test.go +++ b/statecheck/expect_known_value_test.go @@ -28,10 +28,8 @@ func TestExpectKnownValue_CheckState_ResourceNotFound(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -407,10 +405,13 @@ func TestExpectKnownValue_CheckState_List(t *testing.T) { r.Test(t, r.TestCase{ ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature + "test7": func() (*schema.Provider, error) { //nolint:unparam // required signature return testProvider(), nil }, }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), + }, Steps: []r.TestStep{ { Config: `resource "test_resource" "one" { @@ -440,10 +441,13 @@ func TestExpectKnownValue_CheckState_List_KnownValueWrongType(t *testing.T) { r.Test(t, r.TestCase{ ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature + "test7": func() (*schema.Provider, error) { //nolint:unparam // required signature return testProvider(), nil }, }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), + }, Steps: []r.TestStep{ { Config: `resource "test_resource" "one" { @@ -471,10 +475,13 @@ func TestExpectKnownValue_CheckState_List_KnownValueWrongValue(t *testing.T) { r.Test(t, r.TestCase{ ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature + "test7": func() (*schema.Provider, error) { //nolint:unparam // required signature return testProvider(), nil }, }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), + }, Steps: []r.TestStep{ { Config: `resource "test_resource" "one" { @@ -504,10 +511,8 @@ func TestExpectKnownValue_CheckState_ListPartial(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -538,10 +543,8 @@ func TestExpectKnownValue_CheckState_ListPartial_KnownValueWrongValue(t *testing t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -571,10 +574,8 @@ func TestExpectKnownValue_CheckState_ListElements(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -601,10 +602,8 @@ func TestExpectKnownValue_CheckState_ListElements_WrongNum(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { diff --git a/statecheck/test_provider_test.go b/statecheck/test_provider_test.go index c36b5eca7..9cf65b6e4 100644 --- a/statecheck/test_provider_test.go +++ b/statecheck/test_provider_test.go @@ -42,6 +42,11 @@ var anTestProvider = testprovider.Provider{ Type: tftypes.String, Computed: true, }, + { + Name: "list_attribute", + Type: tftypes.List{ElementType: tftypes.String}, + Optional: true, + }, }, }, }, From dee860a51335cdbee8309948e5c64d7386aec9c4 Mon Sep 17 00:00:00 2001 From: Baraa Basata Date: Wed, 26 Feb 2025 08:25:21 -0500 Subject: [PATCH 08/11] more green --- statecheck/expect_known_value_test.go | 18 ++++++------------ statecheck/test_provider_test.go | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/statecheck/expect_known_value_test.go b/statecheck/expect_known_value_test.go index f553ad423..6adc3dabf 100644 --- a/statecheck/expect_known_value_test.go +++ b/statecheck/expect_known_value_test.go @@ -631,10 +631,8 @@ func TestExpectKnownValue_CheckState_ListNestedBlock(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -670,10 +668,8 @@ func TestExpectKnownValue_CheckState_ListNestedBlockPartial(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -706,10 +702,8 @@ func TestExpectKnownValue_CheckState_ListNestedBlockElements(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { diff --git a/statecheck/test_provider_test.go b/statecheck/test_provider_test.go index 9cf65b6e4..e114a7a71 100644 --- a/statecheck/test_provider_test.go +++ b/statecheck/test_provider_test.go @@ -48,6 +48,21 @@ var anTestProvider = testprovider.Provider{ Optional: true, }, }, + BlockTypes: []*tfprotov6.SchemaNestedBlock{ + { + TypeName: "list_nested_block", + Nesting: 2, + Block: &tfprotov6.SchemaBlock{ + Attributes: []*tfprotov6.SchemaAttribute{ + { + Name: "list_nested_block_attribute", + Type: tftypes.String, + Optional: true, + }, + }, + }, + }, + }, }, }, }, From 74ee7d2380ff06b175b58351eb1eb2806da2411b Mon Sep 17 00:00:00 2001 From: Baraa Basata Date: Wed, 26 Feb 2025 08:25:21 -0500 Subject: [PATCH 09/11] more green --- statecheck/test_provider_test.go | 44 ++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/statecheck/test_provider_test.go b/statecheck/test_provider_test.go index e114a7a71..b911a5dbb 100644 --- a/statecheck/test_provider_test.go +++ b/statecheck/test_provider_test.go @@ -47,6 +47,16 @@ var anTestProvider = testprovider.Provider{ Type: tftypes.List{ElementType: tftypes.String}, Optional: true, }, + { + Name: "map_attribute", + Type: tftypes.Map{ElementType: tftypes.String}, + Optional: true, + }, + { + Name: "set_attribute", + Type: tftypes.Set{ElementType: tftypes.String}, + Optional: true, + }, }, BlockTypes: []*tfprotov6.SchemaNestedBlock{ { @@ -62,6 +72,40 @@ var anTestProvider = testprovider.Provider{ }, }, }, + { + TypeName: "set_nested_block", + Nesting: 3, + Block: &tfprotov6.SchemaBlock{ + Attributes: []*tfprotov6.SchemaAttribute{ + { + Name: "set_nested_block_attribute", + Type: tftypes.String, + Optional: true, + }, + }, + }, + }, + { + TypeName: "set_nested_nested_block", + Nesting: 3, + Block: &tfprotov6.SchemaBlock{ + BlockTypes: []*tfprotov6.SchemaNestedBlock{ + { + TypeName: "set_nested_block", + Nesting: 4, + Block: &tfprotov6.SchemaBlock{ + Attributes: []*tfprotov6.SchemaAttribute{ + { + Name: "set_nested_block_attribute", + Type: tftypes.String, + Optional: true, + }, + }, + }, + }, + }, + }, + }, }, }, }, From 4b07f34a9e7e25b28561709b649e95ca5221c1e2 Mon Sep 17 00:00:00 2001 From: Baraa Basata Date: Wed, 26 Feb 2025 08:25:21 -0500 Subject: [PATCH 10/11] more green --- statecheck/compare_value_collection_test.go | 184 +++++++-------- statecheck/expect_known_value_test.go | 240 +++----------------- 2 files changed, 123 insertions(+), 301 deletions(-) diff --git a/statecheck/compare_value_collection_test.go b/statecheck/compare_value_collection_test.go index 31cdc9ec0..7c0b2b320 100644 --- a/statecheck/compare_value_collection_test.go +++ b/statecheck/compare_value_collection_test.go @@ -9,7 +9,6 @@ import ( "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-go/tftypes" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-testing/compare" r "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -25,10 +24,8 @@ func TestCompareValueCollection_CheckState_Bool_Error_NotCollection(t *testing.T t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -61,10 +58,8 @@ func TestCompareValueCollection_CheckState_Float_Error_NotCollection(t *testing. t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -97,10 +92,8 @@ func TestCompareValueCollection_CheckState_Int_Error_NotCollection(t *testing.T) t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -133,10 +126,8 @@ func TestCompareValueCollection_CheckState_List_ValuesSame_ErrorDiffer(t *testin t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -172,10 +163,8 @@ func TestCompareValueCollection_CheckState_EmptyCollectionPath(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -210,10 +199,8 @@ func TestCompareValueCollection_CheckState_List_ValuesSame(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -248,10 +235,8 @@ func TestCompareValueCollection_CheckState_List_ValuesDiffer_ErrorSame(t *testin t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -287,10 +272,8 @@ func TestCompareValueCollection_CheckState_List_ValuesDiffer(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -325,10 +308,8 @@ func TestCompareValueCollection_CheckState_ListNestedBlock_ValuesSame_ErrorDiffe t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -367,6 +348,9 @@ func TestCompareValueCollection_CheckState_ListNestedBlock_ValuesSame(t *testing t.Parallel() r.Test(t, r.TestCase{ + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), + }, ProviderFactories: map[string]func() (*schema.Provider, error){ "test": func() (*schema.Provider, error) { //nolint:unparam // required signature return testProvider(), nil @@ -408,10 +392,8 @@ func TestCompareValueCollection_CheckState_ListNestedBlock_ValuesDiffer_ErrorSam t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -450,10 +432,8 @@ func TestCompareValueCollection_CheckState_ListNestedBlock_ValuesDiffer(t *testi t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -491,10 +471,8 @@ func TestCompareValueCollection_CheckState_Map_ValuesSame_ErrorDiffer(t *testing t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -530,10 +508,8 @@ func TestCompareValueCollection_CheckState_Map_ValuesSame(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -568,10 +544,8 @@ func TestCompareValueCollection_CheckState_Map_ValuesDiffer_ErrorSame(t *testing t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -607,10 +581,8 @@ func TestCompareValueCollection_CheckState_Map_ValuesDiffer(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -645,10 +617,8 @@ func TestCompareValueCollection_CheckState_Set_ValuesSame_ErrorDiffer(t *testing t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -684,10 +654,8 @@ func TestCompareValueCollection_CheckState_Set_ValuesSame(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -722,10 +690,8 @@ func TestCompareValueCollection_CheckState_Set_ValuesDiffer_ErrorSame(t *testing t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -761,10 +727,8 @@ func TestCompareValueCollection_CheckState_Set_ValuesDiffer(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -799,10 +763,8 @@ func TestCompareValueCollection_CheckState_SetNestedBlock_ValuesSame_ErrorDiffer t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -841,10 +803,8 @@ func TestCompareValueCollection_CheckState_SetNestedBlock_ValuesSame(t *testing. t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -882,10 +842,8 @@ func TestCompareValueCollection_CheckState_SetNestedBlock_ValuesDiffer_ErrorSame t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -924,10 +882,8 @@ func TestCompareValueCollection_CheckState_SetNestedBlock_ValuesDiffer(t *testin t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -965,6 +921,9 @@ func TestCompareValueCollection_CheckState_SetNestedNestedBlock_ValuesDiffer_Err t.Parallel() r.Test(t, r.TestCase{ + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), + }, ProviderFactories: map[string]func() (*schema.Provider, error){ "test": func() (*schema.Provider, error) { //nolint:unparam // required signature return testProvider(), nil @@ -1011,6 +970,9 @@ func TestCompareValueCollection_CheckState_SetNestedNestedBlock_ValuesDiffer_Err t.Parallel() r.Test(t, r.TestCase{ + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), + }, ProviderFactories: map[string]func() (*schema.Provider, error){ "test": func() (*schema.Provider, error) { //nolint:unparam // required signature return testProvider(), nil @@ -1056,6 +1018,9 @@ func TestCompareValueCollection_CheckState_SetNestedNestedBlock_ValuesDiffer_Err t.Parallel() r.Test(t, r.TestCase{ + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), + }, ProviderFactories: map[string]func() (*schema.Provider, error){ "test": func() (*schema.Provider, error) { //nolint:unparam // required signature return testProvider(), nil @@ -1100,6 +1065,9 @@ func TestCompareValueCollection_CheckState_SetNestedNestedBlock_ValuesDifferAttr t.Parallel() r.Test(t, r.TestCase{ + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), + }, ProviderFactories: map[string]func() (*schema.Provider, error){ "test": func() (*schema.Provider, error) { //nolint:unparam // required signature return testProvider(), nil @@ -1159,6 +1127,9 @@ func TestCompareValueCollection_CheckState_SetNestedNestedBlock_ValuesDifferNest t.Parallel() r.Test(t, r.TestCase{ + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), + }, ProviderFactories: map[string]func() (*schema.Provider, error){ "test": func() (*schema.Provider, error) { //nolint:unparam // required signature return testProvider(), nil @@ -1217,6 +1188,9 @@ func TestCompareValueCollection_CheckState_SetNestedNestedBlock_ValuesDifferNest t.Parallel() r.Test(t, r.TestCase{ + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), + }, ProviderFactories: map[string]func() (*schema.Provider, error){ "test": func() (*schema.Provider, error) { //nolint:unparam // required signature return testProvider(), nil @@ -1274,6 +1248,9 @@ func TestCompareValueCollection_CheckState_SetNested_ValuesSame_ErrorAttribute(t t.Parallel() r.Test(t, r.TestCase{ + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), + }, ProviderFactories: map[string]func() (*schema.Provider, error){ "test": func() (*schema.Provider, error) { //nolint:unparam // required signature return testProvider(), nil @@ -1334,6 +1311,9 @@ func TestCompareValueCollection_CheckState_SetNested_ValuesSame_ErrorNestedBlock t.Parallel() r.Test(t, r.TestCase{ + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), + }, ProviderFactories: map[string]func() (*schema.Provider, error){ "test": func() (*schema.Provider, error) { //nolint:unparam // required signature return testProvider(), nil @@ -1393,6 +1373,9 @@ func TestCompareValueCollection_CheckState_SetNested_ValuesSame_ErrorNestedNeste t.Parallel() r.Test(t, r.TestCase{ + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), + }, ProviderFactories: map[string]func() (*schema.Provider, error){ "test": func() (*schema.Provider, error) { //nolint:unparam // required signature return testProvider(), nil @@ -1451,6 +1434,9 @@ func TestCompareValueCollection_CheckState_SetNested_ValuesSameAttribute(t *test t.Parallel() r.Test(t, r.TestCase{ + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), + }, ProviderFactories: map[string]func() (*schema.Provider, error){ "test": func() (*schema.Provider, error) { //nolint:unparam // required signature return testProvider(), nil @@ -1510,6 +1496,9 @@ func TestCompareValueCollection_CheckState_SetNested_ValuesSameNestedBlock(t *te t.Parallel() r.Test(t, r.TestCase{ + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), + }, ProviderFactories: map[string]func() (*schema.Provider, error){ "test": func() (*schema.Provider, error) { //nolint:unparam // required signature return testProvider(), nil @@ -1568,6 +1557,9 @@ func TestCompareValueCollection_CheckState_SetNested_ValuesSameNestedNestedBlock t.Parallel() r.Test(t, r.TestCase{ + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), + }, ProviderFactories: map[string]func() (*schema.Provider, error){ "test": func() (*schema.Provider, error) { //nolint:unparam // required signature return testProvider(), nil @@ -1625,10 +1617,8 @@ func TestCompareValueCollection_CheckState_String_Error_NotCollection(t *testing t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { diff --git a/statecheck/expect_known_value_test.go b/statecheck/expect_known_value_test.go index 6adc3dabf..5d0ef7785 100644 --- a/statecheck/expect_known_value_test.go +++ b/statecheck/expect_known_value_test.go @@ -14,8 +14,6 @@ import ( "github.com/google/go-cmp/cmp" tfjson "github.com/hashicorp/terraform-json" "github.com/hashicorp/terraform-plugin-go/tfprotov6" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" r "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/providerserver" @@ -54,10 +52,8 @@ func TestExpectKnownValue_CheckState_AttributeValueNull(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -118,10 +114,8 @@ func TestExpectKnownValue_CheckState_AttributeValueNotNull(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -404,11 +398,6 @@ func TestExpectKnownValue_CheckState_List(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test7": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, - }, ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(anTestProvider), }, @@ -440,11 +429,6 @@ func TestExpectKnownValue_CheckState_List_KnownValueWrongType(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test7": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, - }, ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(anTestProvider), }, @@ -474,11 +458,6 @@ func TestExpectKnownValue_CheckState_List_KnownValueWrongValue(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test7": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, - }, ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(anTestProvider), }, @@ -732,10 +711,8 @@ func TestExpectKnownValue_CheckState_Map(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -765,10 +742,8 @@ func TestExpectKnownValue_CheckState_Map_KnownValueWrongType(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -796,10 +771,8 @@ func TestExpectKnownValue_CheckState_Map_KnownValueWrongValue(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -830,10 +803,8 @@ func TestExpectKnownValue_CheckState_MapPartial(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -862,10 +833,8 @@ func TestExpectKnownValue_CheckState_MapPartial_KnownValueWrongValue(t *testing. t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -895,10 +864,8 @@ func TestExpectKnownValue_CheckState_MapElements(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -925,10 +892,8 @@ func TestExpectKnownValue_CheckState_MapElements_WrongNum(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1019,10 +984,8 @@ func TestExpectKnownValue_CheckState_Set(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1052,10 +1015,8 @@ func TestExpectKnownValue_CheckState_Set_KnownValueWrongValue(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1086,10 +1047,8 @@ func TestExpectKnownValue_CheckState_SetPartial(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1118,10 +1077,8 @@ func TestExpectKnownValue_CheckState_SetPartial_KnownValueWrongValue(t *testing. t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1151,10 +1108,8 @@ func TestExpectKnownValue_CheckState_SetElements(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1181,10 +1136,8 @@ func TestExpectKnownValue_CheckState_SetNestedBlock(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1220,10 +1173,8 @@ func TestExpectKnownValue_CheckState_SetNestedBlock_Custom(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1259,10 +1210,8 @@ func TestExpectKnownValue_CheckState_SetNestedBlockPartial(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1295,10 +1244,8 @@ func TestExpectKnownValue_CheckState_SetNestedBlockElements(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1507,118 +1454,3 @@ var equateErrorMessage = cmp.Comparer(func(x, y error) bool { return x.Error() == y.Error() }) - -func testProvider() *schema.Provider { - return &schema.Provider{ - ResourcesMap: map[string]*schema.Resource{ - "test_resource": { - CreateContext: func(_ context.Context, d *schema.ResourceData, _ interface{}) diag.Diagnostics { - d.SetId("test") - - err := d.Set("string_computed_attribute", "computed") - if err != nil { - return diag.Errorf("error setting string_computed_attribute: %s", err) - } - - return nil - }, - UpdateContext: func(_ context.Context, _ *schema.ResourceData, _ interface{}) diag.Diagnostics { - return nil - }, - DeleteContext: func(_ context.Context, _ *schema.ResourceData, _ interface{}) diag.Diagnostics { - return nil - }, - ReadContext: func(_ context.Context, _ *schema.ResourceData, _ interface{}) diag.Diagnostics { - return nil - }, - Schema: map[string]*schema.Schema{ - "bool_attribute": { - Optional: true, - Type: schema.TypeBool, - }, - "float_attribute": { - Optional: true, - Type: schema.TypeFloat, - }, - "int_attribute": { - Optional: true, - Type: schema.TypeInt, - }, - "list_attribute": { - Type: schema.TypeList, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Optional: true, - }, - "list_nested_block": { - Type: schema.TypeList, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "list_nested_block_attribute": { - Type: schema.TypeString, - Optional: true, - }, - }, - }, - }, - "map_attribute": { - Type: schema.TypeMap, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Optional: true, - }, - "set_attribute": { - Type: schema.TypeSet, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Optional: true, - }, - "set_nested_block": { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "set_nested_block_attribute": { - Type: schema.TypeString, - Optional: true, - }, - }, - }, - }, - "set_nested_nested_block": { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "set_nested_block": { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "set_nested_block_attribute": { - Type: schema.TypeString, - Optional: true, - }, - }, - }, - }, - }, - }, - }, - "string_attribute": { - Optional: true, - Type: schema.TypeString, - }, - "string_computed_attribute": { - Computed: true, - Type: schema.TypeString, - }, - }, - }, - }, - } -} From 7f2cf23b4757affc32f0266549a491d7deb4ec39 Mon Sep 17 00:00:00 2001 From: Baraa Basata Date: Wed, 26 Feb 2025 10:11:56 -0500 Subject: [PATCH 11/11] green --- statecheck/compare_value_collection_test.go | 65 ----- statecheck/compare_value_pairs_test.go | 28 +- statecheck/compare_value_test.go | 34 +-- .../expect_known_output_value_at_path_test.go | 255 ++++++------------ statecheck/expect_known_output_value_test.go | 255 ++++++------------ statecheck/test_provider_test.go | 11 +- 6 files changed, 197 insertions(+), 451 deletions(-) diff --git a/statecheck/compare_value_collection_test.go b/statecheck/compare_value_collection_test.go index 7c0b2b320..b0d97068c 100644 --- a/statecheck/compare_value_collection_test.go +++ b/statecheck/compare_value_collection_test.go @@ -351,11 +351,6 @@ func TestCompareValueCollection_CheckState_ListNestedBlock_ValuesSame(t *testing ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(anTestProvider), }, - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, - }, Steps: []r.TestStep{ { Config: `resource "test_resource" "one" { @@ -924,11 +919,6 @@ func TestCompareValueCollection_CheckState_SetNestedNestedBlock_ValuesDiffer_Err ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(anTestProvider), }, - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, - }, Steps: []r.TestStep{ { Config: `resource "test_resource" "one" { @@ -973,11 +963,6 @@ func TestCompareValueCollection_CheckState_SetNestedNestedBlock_ValuesDiffer_Err ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(anTestProvider), }, - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, - }, Steps: []r.TestStep{ { Config: `resource "test_resource" "one" { @@ -1021,11 +1006,6 @@ func TestCompareValueCollection_CheckState_SetNestedNestedBlock_ValuesDiffer_Err ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(anTestProvider), }, - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, - }, Steps: []r.TestStep{ { Config: `resource "test_resource" "one" { @@ -1068,11 +1048,6 @@ func TestCompareValueCollection_CheckState_SetNestedNestedBlock_ValuesDifferAttr ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(anTestProvider), }, - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, - }, Steps: []r.TestStep{ { Config: `resource "test_resource" "one" { @@ -1130,11 +1105,6 @@ func TestCompareValueCollection_CheckState_SetNestedNestedBlock_ValuesDifferNest ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(anTestProvider), }, - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, - }, Steps: []r.TestStep{ { Config: `resource "test_resource" "one" { @@ -1191,11 +1161,6 @@ func TestCompareValueCollection_CheckState_SetNestedNestedBlock_ValuesDifferNest ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(anTestProvider), }, - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, - }, Steps: []r.TestStep{ { Config: `resource "test_resource" "one" { @@ -1251,11 +1216,6 @@ func TestCompareValueCollection_CheckState_SetNested_ValuesSame_ErrorAttribute(t ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(anTestProvider), }, - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, - }, Steps: []r.TestStep{ { Config: `resource "test_resource" "one" { @@ -1314,11 +1274,6 @@ func TestCompareValueCollection_CheckState_SetNested_ValuesSame_ErrorNestedBlock ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(anTestProvider), }, - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, - }, Steps: []r.TestStep{ { Config: `resource "test_resource" "one" { @@ -1376,11 +1331,6 @@ func TestCompareValueCollection_CheckState_SetNested_ValuesSame_ErrorNestedNeste ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(anTestProvider), }, - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, - }, Steps: []r.TestStep{ { Config: `resource "test_resource" "one" { @@ -1437,11 +1387,6 @@ func TestCompareValueCollection_CheckState_SetNested_ValuesSameAttribute(t *test ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(anTestProvider), }, - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, - }, Steps: []r.TestStep{ { Config: `resource "test_resource" "one" { @@ -1499,11 +1444,6 @@ func TestCompareValueCollection_CheckState_SetNested_ValuesSameNestedBlock(t *te ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(anTestProvider), }, - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, - }, Steps: []r.TestStep{ { Config: `resource "test_resource" "one" { @@ -1560,11 +1500,6 @@ func TestCompareValueCollection_CheckState_SetNested_ValuesSameNestedNestedBlock ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ "test": providerserver.NewProviderServer(anTestProvider), }, - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, - }, Steps: []r.TestStep{ { Config: `resource "test_resource" "one" { diff --git a/statecheck/compare_value_pairs_test.go b/statecheck/compare_value_pairs_test.go index 4df478832..991c285d7 100644 --- a/statecheck/compare_value_pairs_test.go +++ b/statecheck/compare_value_pairs_test.go @@ -7,10 +7,10 @@ import ( "regexp" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - + "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-testing/compare" r "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/providerserver" "github.com/hashicorp/terraform-plugin-testing/statecheck" "github.com/hashicorp/terraform-plugin-testing/tfjsonpath" ) @@ -19,10 +19,8 @@ func TestCompareValuePairs_CheckState_ValuesSame_DifferError(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -50,10 +48,8 @@ func TestCompareValuePairs_CheckState_ValuesSame(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -83,10 +79,8 @@ func TestCompareValuePairs_CheckState_ValuesDiffer_SameError(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -116,10 +110,8 @@ func TestCompareValuePairs_CheckState_ValuesDiffer(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { diff --git a/statecheck/compare_value_test.go b/statecheck/compare_value_test.go index 271692425..9f89484ea 100644 --- a/statecheck/compare_value_test.go +++ b/statecheck/compare_value_test.go @@ -7,10 +7,10 @@ import ( "regexp" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - + "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-testing/compare" r "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/providerserver" "github.com/hashicorp/terraform-plugin-testing/statecheck" "github.com/hashicorp/terraform-plugin-testing/tfjsonpath" ) @@ -21,10 +21,8 @@ func TestCompareValue_CheckState_NoStateValues(t *testing.T) { boolValuesDiffer := statecheck.CompareValue(compare.ValuesSame()) r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -48,10 +46,8 @@ func TestCompareValue_CheckState_ValuesSame_ValueDiffersError(t *testing.T) { boolValuesDiffer := statecheck.CompareValue(compare.ValuesSame()) r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -101,10 +97,8 @@ func TestCompareValue_CheckState_ValuesSame(t *testing.T) { boolValuesDiffer := statecheck.CompareValue(compare.ValuesSame()) r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -141,10 +135,8 @@ func TestCompareValue_CheckState_ValuesDiffer_ValueSameError(t *testing.T) { boolValuesDiffer := statecheck.CompareValue(compare.ValuesDiffer()) r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -194,10 +186,8 @@ func TestCompareValue_CheckState_ValuesDiffer(t *testing.T) { boolValuesDiffer := statecheck.CompareValue(compare.ValuesDiffer()) r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { diff --git a/statecheck/expect_known_output_value_at_path_test.go b/statecheck/expect_known_output_value_at_path_test.go index 0b6013bcd..8750ff1bd 100644 --- a/statecheck/expect_known_output_value_at_path_test.go +++ b/statecheck/expect_known_output_value_at_path_test.go @@ -12,9 +12,10 @@ import ( "github.com/google/go-cmp/cmp" tfjson "github.com/hashicorp/terraform-json" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" r "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/providerserver" "github.com/hashicorp/terraform-plugin-testing/knownvalue" "github.com/hashicorp/terraform-plugin-testing/statecheck" "github.com/hashicorp/terraform-plugin-testing/tfjsonpath" @@ -24,10 +25,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_ResourceNotFound(t *testing.T) t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -56,10 +55,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_AttributeValueNull(t *testing.T t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -125,10 +122,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_AttributeValueNotNull(t *testin t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -210,10 +205,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_Bool(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -241,10 +234,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_Bool_KnownValueWrongType(t *tes t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -273,10 +264,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_Bool_KnownValueWrongValue(t *te t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -305,10 +294,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_Float64(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -337,10 +324,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_Float64_KnownValueWrongType(t * t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -369,10 +354,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_Float64_KnownValueWrongValue(t t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -401,10 +384,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_Int64(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -432,10 +413,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_Int64_KnownValueWrongValue(t *t t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -464,10 +443,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_List(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -501,10 +478,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_List_KnownValueWrongType(t *tes t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -536,10 +511,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_List_KnownValueWrongValue(t *te t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -574,10 +547,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_ListPartial(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -612,10 +583,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_ListPartial_KnownValueWrongValu t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -649,10 +618,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_ListElements(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -683,10 +650,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_ListElements_WrongNum(t *testin t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -718,10 +683,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_ListNestedBlock(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -761,10 +724,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_ListNestedBlockPartial(t *testi t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -801,10 +762,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_ListNestedBlockElements(t *test t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -837,10 +796,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_Map(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -874,10 +831,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_Map_KnownValueWrongType(t *test t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -909,10 +864,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_Map_KnownValueWrongValue(t *tes t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -947,10 +900,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_MapPartial(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -983,10 +934,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_MapPartial_KnownValueWrongValue t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1020,10 +969,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_MapElements(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1054,10 +1001,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_MapElements_WrongNum(t *testing t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1095,10 +1040,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_Number(t *testing.T) { } r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1132,10 +1075,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_Number_KnownValueWrongValue(t * } r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1164,10 +1105,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_Set(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1201,10 +1140,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_Set_KnownValueWrongValue(t *tes t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1239,10 +1176,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_SetPartial(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1275,10 +1210,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_SetPartial_KnownValueWrongValue t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1312,10 +1245,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_SetElements(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1346,10 +1277,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_SetNestedBlock(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1389,10 +1318,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_SetNestedBlockPartial(t *testin t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1429,10 +1356,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_SetNestedBlockElements(t *testi t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1465,10 +1390,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_String(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1495,10 +1418,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_String_Custom(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1525,10 +1446,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_String_KnownValueWrongType(t *t t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1556,10 +1475,8 @@ func TestExpectKnownOutputValueAtPath_CheckState_String_KnownValueWrongValue(t * t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { diff --git a/statecheck/expect_known_output_value_test.go b/statecheck/expect_known_output_value_test.go index 62d9067fe..22d6eee9a 100644 --- a/statecheck/expect_known_output_value_test.go +++ b/statecheck/expect_known_output_value_test.go @@ -12,9 +12,10 @@ import ( "github.com/google/go-cmp/cmp" tfjson "github.com/hashicorp/terraform-json" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" r "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/providerserver" "github.com/hashicorp/terraform-plugin-testing/knownvalue" "github.com/hashicorp/terraform-plugin-testing/statecheck" ) @@ -23,10 +24,8 @@ func TestExpectKnownOutputValue_CheckState_OutputNotFound(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -58,10 +57,8 @@ func TestExpectKnownOutputValue_CheckState_AttributeValueNull(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -86,10 +83,8 @@ func TestExpectKnownOutputValue_CheckState_AttributeValueNotNull(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -185,10 +180,8 @@ func TestExpectKnownOutputValue_CheckState_Bool(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -215,10 +208,8 @@ func TestExpectKnownOutputValue_CheckState_Bool_KnownValueWrongType(t *testing.T t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -246,10 +237,8 @@ func TestExpectKnownOutputValue_CheckState_Bool_KnownValueWrongValue(t *testing. t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -277,10 +266,8 @@ func TestExpectKnownOutputValue_CheckState_Float64(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -308,10 +295,8 @@ func TestExpectKnownOutputValue_CheckState_Float64_KnownValueWrongType(t *testin t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -339,10 +324,8 @@ func TestExpectKnownOutputValue_CheckState_Float64_KnownValueWrongValue(t *testi t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -370,10 +353,8 @@ func TestExpectKnownOutputValue_CheckState_Int64(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -400,10 +381,8 @@ func TestExpectKnownOutputValue_CheckState_Int64_KnownValueWrongValue(t *testing t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -431,10 +410,8 @@ func TestExpectKnownOutputValue_CheckState_List(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -467,10 +444,8 @@ func TestExpectKnownOutputValue_CheckState_List_KnownValueWrongType(t *testing.T t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -501,10 +476,8 @@ func TestExpectKnownOutputValue_CheckState_List_KnownValueWrongValue(t *testing. t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -538,10 +511,8 @@ func TestExpectKnownOutputValue_CheckState_ListPartial(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -575,10 +546,8 @@ func TestExpectKnownOutputValue_CheckState_ListPartial_KnownValueWrongValue(t *t t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -611,10 +580,8 @@ func TestExpectKnownOutputValue_CheckState_ListElements(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -644,10 +611,8 @@ func TestExpectKnownOutputValue_CheckState_ListElements_WrongNum(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -678,10 +643,8 @@ func TestExpectKnownOutputValue_CheckState_ListNestedBlock(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -720,10 +683,8 @@ func TestExpectKnownOutputValue_CheckState_ListNestedBlockPartial(t *testing.T) t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -759,10 +720,8 @@ func TestExpectKnownOutputValue_CheckState_ListNestedBlockElements(t *testing.T) t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -794,10 +753,8 @@ func TestExpectKnownOutputValue_CheckState_Map(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -830,10 +787,8 @@ func TestExpectKnownOutputValue_CheckState_Map_KnownValueWrongType(t *testing.T) t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -864,10 +819,8 @@ func TestExpectKnownOutputValue_CheckState_Map_KnownValueWrongValue(t *testing.T t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -901,10 +854,8 @@ func TestExpectKnownOutputValue_CheckState_MapPartial(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -936,10 +887,8 @@ func TestExpectKnownOutputValue_CheckState_MapPartial_KnownValueWrongValue(t *te t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -972,10 +921,8 @@ func TestExpectKnownOutputValue_CheckState_MapElements(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1005,10 +952,8 @@ func TestExpectKnownOutputValue_CheckState_MapElements_WrongNum(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1045,10 +990,8 @@ func TestExpectKnownOutputValue_CheckState_Number(t *testing.T) { } r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1081,10 +1024,8 @@ func TestExpectKnownOutputValue_CheckState_Number_KnownValueWrongValue(t *testin } r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1112,10 +1053,8 @@ func TestExpectKnownOutputValue_CheckState_Set(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1148,10 +1087,8 @@ func TestExpectKnownOutputValue_CheckState_Set_KnownValueWrongValue(t *testing.T t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1185,10 +1122,8 @@ func TestExpectKnownOutputValue_CheckState_SetPartial(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1220,10 +1155,8 @@ func TestExpectKnownOutputValue_CheckState_SetPartial_KnownValueWrongValue(t *te t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1256,10 +1189,8 @@ func TestExpectKnownOutputValue_CheckState_SetElements(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1289,10 +1220,8 @@ func TestExpectKnownOutputValue_CheckState_SetNestedBlock(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1331,10 +1260,8 @@ func TestExpectKnownOutputValue_CheckState_SetNestedBlockPartial(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1370,10 +1297,8 @@ func TestExpectKnownOutputValue_CheckState_SetNestedBlockElements(t *testing.T) t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1405,10 +1330,8 @@ func TestExpectKnownOutputValue_CheckState_String(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1434,10 +1357,8 @@ func TestExpectKnownOutputValue_CheckState_String_Custom(t *testing.T) { t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1463,10 +1384,8 @@ func TestExpectKnownOutputValue_CheckState_String_KnownValueWrongType(t *testing t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { @@ -1493,10 +1412,8 @@ func TestExpectKnownOutputValue_CheckState_String_KnownValueWrongValue(t *testin t.Parallel() r.Test(t, r.TestCase{ - ProviderFactories: map[string]func() (*schema.Provider, error){ - "test": func() (*schema.Provider, error) { //nolint:unparam // required signature - return testProvider(), nil - }, + ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error){ + "test": providerserver.NewProviderServer(anTestProvider), }, Steps: []r.TestStep{ { diff --git a/statecheck/test_provider_test.go b/statecheck/test_provider_test.go index b911a5dbb..d29fedee8 100644 --- a/statecheck/test_provider_test.go +++ b/statecheck/test_provider_test.go @@ -37,11 +37,6 @@ var anTestProvider = testprovider.Provider{ Type: tftypes.String, Optional: true, }, - { - Name: "string_computed_attribute", - Type: tftypes.String, - Computed: true, - }, { Name: "list_attribute", Type: tftypes.List{ElementType: tftypes.String}, @@ -74,7 +69,7 @@ var anTestProvider = testprovider.Provider{ }, { TypeName: "set_nested_block", - Nesting: 3, + Nesting: tfprotov6.SchemaNestedBlockNestingModeList, Block: &tfprotov6.SchemaBlock{ Attributes: []*tfprotov6.SchemaAttribute{ { @@ -87,12 +82,12 @@ var anTestProvider = testprovider.Provider{ }, { TypeName: "set_nested_nested_block", - Nesting: 3, + Nesting: tfprotov6.SchemaNestedBlockNestingModeSet, Block: &tfprotov6.SchemaBlock{ BlockTypes: []*tfprotov6.SchemaNestedBlock{ { TypeName: "set_nested_block", - Nesting: 4, + Nesting: tfprotov6.SchemaNestedBlockNestingModeSet, Block: &tfprotov6.SchemaBlock{ Attributes: []*tfprotov6.SchemaAttribute{ {