Skip to content

Commit 246c306

Browse files
Remove ID attribute from schema in test providers (#3121)
This PR removes the mandatory addition of an "id" property to all TF schemas created by the `pulcheck` test library. That is not necessary in TF so we should not be requiring it in our tests. It also adds some additional checks for some of our tests. This is a test-only change.
1 parent 4a92a2f commit 246c306

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

internal/testprovider/schema.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
terraformv1 "github.com/hashicorp/terraform-plugin-sdk/terraform"
2323
schemav2 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
2424
terraformv2 "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
25+
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
2526
)
2627

2728
type Settable interface {
@@ -52,7 +53,7 @@ func Timeout(d time.Duration) *time.Duration {
5253
}
5354

5455
func ProviderV1() *schemav1.Provider {
55-
return &schemav1.Provider{
56+
prov := &schemav1.Provider{
5657
Schema: map[string]*schemav1.Schema{
5758
"config_value": {Type: schemav1.TypeString, Optional: true},
5859
},
@@ -429,10 +430,13 @@ func ProviderV1() *schemav1.Provider {
429430
return nil, nil
430431
},
431432
}
433+
434+
contract.AssertNoErrorf(prov.InternalValidate(), "InternalValidate failed")
435+
return prov
432436
}
433437

434438
func ProviderV2() *schemav2.Provider {
435-
return &schemav2.Provider{
439+
prov := &schemav2.Provider{
436440
Schema: map[string]*schemav2.Schema{
437441
"config_value": {Type: schemav2.TypeString, Optional: true},
438442
},
@@ -832,6 +836,9 @@ func ProviderV2() *schemav2.Provider {
832836
return nil, nil
833837
},
834838
}
839+
contract.AssertNoErrorf(prov.InternalValidate(), "InternalValidate failed")
840+
841+
return prov
835842
}
836843

837844
func AssertProvider(f func(data *schemav2.ResourceData)) *schemav2.Provider {

pkg/internal/tests/pulcheck/pulcheck.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,6 @@ func WithValidProvider(t T, tfp *schema.Provider) *schema.Provider {
8686
// Now ensure that tfp is valid
8787

8888
for _, r := range tfp.ResourcesMap {
89-
if r.Schema["id"] == nil {
90-
r.Schema["id"] = &schema.Schema{
91-
Type: schema.TypeString,
92-
Computed: true,
93-
}
94-
}
95-
9689
// If the resource will be flagged as not needing an Update method by the TF SDK schema
9790
// validation then add a no-op update_prop property that will instead force the resource
9891
// to need an Update method.

0 commit comments

Comments
 (0)