Skip to content

Commit 3047b49

Browse files
committed
Add list_test
1 parent 7e298db commit 3047b49

File tree

2 files changed

+76
-2
lines changed

2 files changed

+76
-2
lines changed

resource/list.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
14
package resource
25

36
import (
@@ -8,14 +11,19 @@ import (
811
)
912

1013
type List interface {
14+
Metadata(context.Context, MetadataRequest, *MetadataResponse)
1115
ListSchema(context.Context, SchemaRequest, SchemaResponse)
1216
ListResources(context.Context, ListRequest, ListResponse)
1317
}
1418

15-
type ListWithValidate interface {
19+
type ListWithConfigure interface {
1620
List
21+
Configure(context.Context, ConfigureRequest, *ConfigureResponse)
22+
}
1723

18-
ValidateListConfig(context.Context, ValidateListConfigRequest, ValidateListConfigResponse)
24+
type ListWithValidateConfig interface {
25+
List
26+
ValidateListConfig(context.Context, ValidateListConfigRequest, *ValidateListConfigResponse)
1927
}
2028

2129
type ListRequest struct {

resource/list_test.go

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
4+
package resource_test
5+
6+
import (
7+
"context"
8+
9+
"github.com/hashicorp/terraform-plugin-framework/resource"
10+
)
11+
12+
type ComputeInstance struct {
13+
}
14+
15+
func (c *ComputeInstance) Configure(_ context.Context, _ resource.ConfigureRequest, _ *resource.ConfigureResponse) {
16+
panic("not implemented")
17+
}
18+
19+
func (c *ComputeInstance) ValidateListConfig(_ context.Context, _ resource.ValidateListConfigRequest, _ *resource.ValidateListConfigResponse) {
20+
panic("not implemented")
21+
}
22+
23+
func (c *ComputeInstance) ListSchema(_ context.Context, _ resource.SchemaRequest, _ resource.SchemaResponse) {
24+
panic("not implemented")
25+
}
26+
27+
func (c *ComputeInstance) ListResources(_ context.Context, _ resource.ListRequest, _ resource.ListResponse) {
28+
panic("not implemented")
29+
}
30+
31+
func (c *ComputeInstance) Metadata(_ context.Context, _ resource.MetadataRequest, _ *resource.MetadataResponse) {
32+
panic("not implemented")
33+
}
34+
35+
func (c *ComputeInstance) Schema(_ context.Context, _ resource.SchemaRequest, _ *resource.SchemaResponse) {
36+
panic("not implemented")
37+
}
38+
39+
func (c *ComputeInstance) Create(_ context.Context, _ resource.CreateRequest, _ *resource.CreateResponse) {
40+
panic("not implemented")
41+
}
42+
43+
func (c *ComputeInstance) Read(_ context.Context, _ resource.ReadRequest, _ *resource.ReadResponse) {
44+
panic("not implemented")
45+
}
46+
47+
func (c *ComputeInstance) Update(_ context.Context, _ resource.UpdateRequest, _ *resource.UpdateResponse) {
48+
panic("not implemented")
49+
}
50+
51+
func (c *ComputeInstance) Delete(_ context.Context, _ resource.DeleteRequest, _ *resource.DeleteResponse) {
52+
panic("not implemented")
53+
}
54+
55+
// ExampleResource_listable demonstrates a resource.Resource that implements resource.List interfaces
56+
func ExampleResource_listable() {
57+
58+
var _ resource.List = &ComputeInstance{}
59+
var _ resource.ListWithConfigure = &ComputeInstance{}
60+
var _ resource.ListWithValidateConfig = &ComputeInstance{}
61+
62+
var _ resource.Resource = &ComputeInstance{}
63+
var _ resource.ResourceWithConfigure = &ComputeInstance{}
64+
65+
// Output:
66+
}

0 commit comments

Comments
 (0)