Skip to content

Commit ae8070f

Browse files
committed
red, but better
1 parent efba631 commit ae8070f

File tree

3 files changed

+44
-27
lines changed

3 files changed

+44
-27
lines changed

statecheck/test_provider_test.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ package statecheck_test
66
import (
77
"context"
88

9+
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
10+
"github.com/hashicorp/terraform-plugin-go/tftypes"
911
"github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/datasource"
1012
"github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/provider"
1113
"github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/resource"
@@ -15,23 +17,30 @@ type aTestProvider struct {
1517
}
1618

1719
func (t aTestProvider) Configure(ctx context.Context, request provider.ConfigureRequest, response *provider.ConfigureResponse) {
18-
//TODO implement me
19-
panic("implement me")
2020
}
2121

2222
func (t aTestProvider) DataSourcesMap() map[string]datasource.DataSource {
23-
//TODO implement me
24-
panic("implement me")
23+
return nil
2524
}
2625

2726
func (t aTestProvider) ResourcesMap() map[string]resource.Resource {
28-
//TODO implement me
29-
panic("implement me")
27+
return map[string]resource.Resource{
28+
"test_resource": &aTestResource{},
29+
}
3030
}
3131

3232
func (t aTestProvider) Schema(ctx context.Context, request provider.SchemaRequest, response *provider.SchemaResponse) {
33-
//TODO implement me
34-
panic("implement me")
33+
schema := tfprotov6.Schema{
34+
Block: &tfprotov6.SchemaBlock{
35+
Attributes: []*tfprotov6.SchemaAttribute{
36+
{
37+
Name: "planet",
38+
Type: tftypes.String,
39+
},
40+
},
41+
},
42+
}
43+
response.Schema = &schema
3544
}
3645

3746
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
4049
}
4150

4251
func (t aTestProvider) ValidateConfig(ctx context.Context, request provider.ValidateConfigRequest, response *provider.ValidateConfigResponse) {
43-
//TODO implement me
44-
panic("implement me")
4552
}

statecheck/test_resource.go

Lines changed: 0 additions & 1 deletion
This file was deleted.

statecheck/test_resource_test.go

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,54 +5,65 @@ package statecheck_test
55

66
import (
77
"context"
8+
9+
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
10+
"github.com/hashicorp/terraform-plugin-go/tftypes"
811
"github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/resource"
912
)
1013

11-
type testResource struct {}
14+
type aTestResource struct{}
1215

13-
func (t testResource) Create(ctx context.Context, request resource.CreateRequest, response *resource.CreateResponse) {
16+
func (t aTestResource) Create(ctx context.Context, request resource.CreateRequest, response *resource.CreateResponse) {
1417
//TODO implement me
1518
panic("implement me")
1619
}
1720

18-
func (t testResource) Delete(ctx context.Context, request resource.DeleteRequest, response *resource.DeleteResponse) {
21+
func (t aTestResource) Delete(ctx context.Context, request resource.DeleteRequest, response *resource.DeleteResponse) {
1922
//TODO implement me
2023
panic("implement me")
2124
}
2225

23-
func (t testResource) ImportState(ctx context.Context, request resource.ImportStateRequest, response *resource.ImportStateResponse) {
26+
func (t aTestResource) ImportState(ctx context.Context, request resource.ImportStateRequest, response *resource.ImportStateResponse) {
2427
//TODO implement me
2528
panic("implement me")
2629
}
2730

28-
func (t testResource) PlanChange(ctx context.Context, request resource.PlanChangeRequest, response *resource.PlanChangeResponse) {
31+
func (t aTestResource) PlanChange(ctx context.Context, request resource.PlanChangeRequest, response *resource.PlanChangeResponse) {
2932
//TODO implement me
3033
panic("implement me")
3134
}
3235

33-
func (t testResource) Read(ctx context.Context, request resource.ReadRequest, response *resource.ReadResponse) {
36+
func (t aTestResource) Read(ctx context.Context, request resource.ReadRequest, response *resource.ReadResponse) {
3437
//TODO implement me
3538
panic("implement me")
3639
}
3740

38-
func (t testResource) Schema(ctx context.Context, request resource.SchemaRequest, response *resource.SchemaResponse) {
39-
//TODO implement me
40-
panic("implement me")
41+
func (t aTestResource) Schema(ctx context.Context, request resource.SchemaRequest, response *resource.SchemaResponse) {
42+
schema := tfprotov6.Schema{
43+
Block: &tfprotov6.SchemaBlock{
44+
Attributes: []*tfprotov6.SchemaAttribute{
45+
{
46+
Name: "bool_attribute",
47+
Type: tftypes.Bool,
48+
Computed: true,
49+
},
50+
},
51+
Description: "",
52+
DescriptionKind: 0,
53+
},
54+
}
55+
response.Schema = &schema
4156
}
4257

43-
func (t testResource) Update(ctx context.Context, request resource.UpdateRequest, response *resource.UpdateResponse) {
58+
func (t aTestResource) Update(ctx context.Context, request resource.UpdateRequest, response *resource.UpdateResponse) {
4459
//TODO implement me
4560
panic("implement me")
4661
}
4762

48-
func (t testResource) UpgradeState(ctx context.Context, request resource.UpgradeStateRequest, response *resource.UpgradeStateResponse) {
63+
func (t aTestResource) UpgradeState(ctx context.Context, request resource.UpgradeStateRequest, response *resource.UpgradeStateResponse) {
4964
//TODO implement me
5065
panic("implement me")
5166
}
5267

53-
func (t testResource) ValidateConfig(ctx context.Context, request resource.ValidateConfigRequest, response *resource.ValidateConfigResponse) {
54-
//TODO implement me
55-
panic("implement me")
68+
func (t aTestResource) ValidateConfig(ctx context.Context, request resource.ValidateConfigRequest, response *resource.ValidateConfigResponse) {
5669
}
57-
58-

0 commit comments

Comments
 (0)