@@ -5,6 +5,7 @@ package fwserver_test
55
66import (
77 "context"
8+ "fmt"
89 "slices"
910 "testing"
1011
@@ -13,6 +14,7 @@ import (
1314 "github.com/hashicorp/terraform-plugin-framework/internal/fwserver"
1415 "github.com/hashicorp/terraform-plugin-framework/internal/testing/testprovider"
1516 "github.com/hashicorp/terraform-plugin-framework/list"
17+ "github.com/hashicorp/terraform-plugin-framework/resource"
1618 "github.com/hashicorp/terraform-plugin-framework/resource/identityschema"
1719 "github.com/hashicorp/terraform-plugin-framework/resource/schema"
1820 "github.com/hashicorp/terraform-plugin-framework/tfsdk"
@@ -182,6 +184,44 @@ func TestServerListResource(t *testing.T) {
182184 expectedStreamEvents : []fwserver.ListResult {},
183185 expectedError : "config cannot be nil" ,
184186 },
187+ "listresource-configure-data" : {
188+ server : & fwserver.Server {
189+ ListResourceConfigureData : "test-provider-configure-value" ,
190+ Provider : & testprovider.Provider {},
191+ },
192+ request : & fwserver.ListRequest {
193+ Config : & tfsdk.Config {},
194+ ListResource : & testprovider.ListResourceWithConfigure {
195+ ConfigureMethod : func (ctx context.Context , req resource.ConfigureRequest , resp * resource.ConfigureResponse ) {
196+ providerData , ok := req .ProviderData .(string )
197+
198+ if ! ok {
199+ resp .Diagnostics .AddError (
200+ "Unexpected ConfigureRequest.ProviderData" ,
201+ fmt .Sprintf ("Expected string, got: %T" , req .ProviderData ),
202+ )
203+ return
204+ }
205+
206+ if providerData != "test-provider-configure-value" {
207+ resp .Diagnostics .AddError (
208+ "Unexpected ConfigureRequest.ProviderData" ,
209+ fmt .Sprintf ("Expected test-provider-configure-value, got: %q" , providerData ),
210+ )
211+ }
212+ },
213+ ListResource : & testprovider.ListResource {
214+ ListMethod : func (ctx context.Context , req list.ListRequest , resp * list.ListResultsStream ) {
215+ // In practice, the Configure method would save the
216+ // provider data to the ListResource implementation and
217+ // use it here. The fact that Configure is able to
218+ // read the data proves this can work.
219+ },
220+ },
221+ },
222+ },
223+ expectedStreamEvents : []fwserver.ListResult {},
224+ },
185225 }
186226
187227 for name , testCase := range testCases {
0 commit comments