Skip to content

Commit

Permalink
Fix the testprovider to not always replace
Browse files Browse the repository at this point in the history
The provider previously triggers replaces on every update, because it replaces on `prefix` but doesn't store it into outputs.  This *also* triggers the new refresh logic to report an update as part of the refresh, but it seems it is indeed just "broken" even outside of refresh, we just weren't testing multiple consecutive updates to these resources previously.
  • Loading branch information
lukehoban committed May 9, 2024
1 parent 0c0b0ba commit d266a15
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/testprovider/random.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ func init() {
TypeSpec: pschema.TypeSpec{Type: "integer"},
Description: "The length of the random string (not including the prefix, if any).",
},
"prefix": {
TypeSpec: pschema.TypeSpec{Type: "string"},
Description: "An optional prefix.",
},
"result": {
TypeSpec: pschema.TypeSpec{Type: "string"},
Description: "A random string.",
Expand Down Expand Up @@ -128,6 +132,9 @@ func (p *randomResourceProvider) Create(ctx context.Context, req *rpc.CreateRequ
"length": n,
"result": prefix + result,
})
if prefix != "" {
outputs["prefix"] = resource.NewStringProperty(prefix)
}
outputs["result"] = resource.MakeSecret(outputs["result"])

outputProperties, err := plugin.MarshalProperties(
Expand Down

0 comments on commit d266a15

Please sign in to comment.