From 2e69e46edca3e0b928f191445116cf9e323ba4fb Mon Sep 17 00:00:00 2001 From: Venelin Date: Wed, 11 Dec 2024 16:30:57 +0000 Subject: [PATCH] Ensure all sdkv2 test providers have an id and an update method --- pkg/internal/tests/pulcheck/pulcheck.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/internal/tests/pulcheck/pulcheck.go b/pkg/internal/tests/pulcheck/pulcheck.go index 94c00e781e..955b449d94 100644 --- a/pkg/internal/tests/pulcheck/pulcheck.go +++ b/pkg/internal/tests/pulcheck/pulcheck.go @@ -53,6 +53,20 @@ func resourceNeedsUpdate(res *schema.Resource) bool { // This is an experimental API. func EnsureProviderValid(t T, tfp *schema.Provider) { for _, r := range tfp.ResourcesMap { + if r.Schema["id"] == nil { + r.Schema["id"] = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + } + } + + if !resourceNeedsUpdate(r) { + r.Schema["update_prop"] = &schema.Schema{ + Type: schema.TypeString, + Optional: true, + } + } + if r.ReadContext == nil { r.ReadContext = func(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { return nil @@ -75,7 +89,7 @@ func EnsureProviderValid(t T, tfp *schema.Provider) { } } - if resourceNeedsUpdate(r) && r.UpdateContext == nil { + if r.UpdateContext == nil { r.UpdateContext = func( ctx context.Context, rd *schema.ResourceData, i interface{}, ) diag.Diagnostics {