@@ -6,6 +6,7 @@ package proto6server
66import (
77 "context"
88 "github.com/hashicorp/terraform-plugin-framework/resource"
9+ "github.com/hashicorp/terraform-plugin-go/tftypes"
910 "testing"
1011
1112 "github.com/google/go-cmp/cmp"
@@ -14,12 +15,19 @@ import (
1415 "github.com/hashicorp/terraform-plugin-framework/list"
1516 "github.com/hashicorp/terraform-plugin-framework/list/schema"
1617 "github.com/hashicorp/terraform-plugin-go/tfprotov6"
17- "github.com/hashicorp/terraform-plugin-go/tftypes"
1818)
1919
2020func TestServerValidateListResourceConfig (t * testing.T ) {
2121 t .Parallel ()
2222
23+ testSchema := schema.Schema {
24+ Attributes : map [string ]schema.Attribute {
25+ "test" : schema.StringAttribute {
26+ Required : true ,
27+ },
28+ },
29+ }
30+
2331 testType := tftypes.Object {
2432 AttributeTypes : map [string ]tftypes.Type {
2533 "test" : tftypes .String ,
@@ -36,14 +44,6 @@ func TestServerValidateListResourceConfig(t *testing.T) {
3644 t .Fatalf ("unexpected error calling tfprotov6.NewDynamicValue(): %s" , err )
3745 }
3846
39- testSchema := schema.Schema {
40- Attributes : map [string ]schema.Attribute {
41- "test" : schema.StringAttribute {
42- Required : true ,
43- },
44- },
45- }
46-
4747 testCases := map [string ]struct {
4848 server * Server
4949 request * tfprotov6.ValidateListResourceConfigRequest
@@ -58,10 +58,21 @@ func TestServerValidateListResourceConfig(t *testing.T) {
5858 return []func () list.ListResource {
5959 func () list.ListResource {
6060 return & testprovider.ListResource {
61- ListResourceConfigSchemaMethod : func (_ context.Context , _ list.ListResourceSchemaRequest , resp * list.ListResourceSchemaResponse ) {},
6261 MetadataMethod : func (_ context.Context , _ resource.MetadataRequest , resp * resource.MetadataResponse ) {
6362 resp .TypeName = "test_resource"
6463 },
64+ ListResourceConfigSchemaMethod : func (_ context.Context , _ list.ListResourceSchemaRequest , resp * list.ListResourceSchemaResponse ) {},
65+ }
66+ },
67+ }
68+ },
69+ ResourcesMethod : func (_ context.Context ) []func () resource.Resource {
70+ return []func () resource.Resource {
71+ func () resource.Resource {
72+ return & testprovider.Resource {
73+ MetadataMethod : func (_ context.Context , _ resource.MetadataRequest , response * resource.MetadataResponse ) {
74+ response .TypeName = "test_resource"
75+ },
6576 }
6677 },
6778 }
@@ -92,6 +103,17 @@ func TestServerValidateListResourceConfig(t *testing.T) {
92103 },
93104 }
94105 },
106+ ResourcesMethod : func (ctx context.Context ) []func () resource.Resource {
107+ return []func () resource.Resource {
108+ func () resource.Resource {
109+ return & testprovider.Resource {
110+ MetadataMethod : func (ctx context.Context , request resource.MetadataRequest , response * resource.MetadataResponse ) {
111+ response .TypeName = "test_resource"
112+ },
113+ }
114+ },
115+ }
116+ },
95117 },
96118 },
97119 },
@@ -125,6 +147,17 @@ func TestServerValidateListResourceConfig(t *testing.T) {
125147 },
126148 }
127149 },
150+ ResourcesMethod : func (ctx context.Context ) []func () resource.Resource {
151+ return []func () resource.Resource {
152+ func () resource.Resource {
153+ return & testprovider.Resource {
154+ MetadataMethod : func (ctx context.Context , request resource.MetadataRequest , response * resource.MetadataResponse ) {
155+ response .TypeName = "test_resource"
156+ },
157+ }
158+ },
159+ }
160+ },
128161 },
129162 },
130163 },
0 commit comments