Skip to content

Commit

Permalink
Test collections refresh (#2072)
Browse files Browse the repository at this point in the history
Related to #2047

Pulling out the tests from
#2065 so that the
changes in behaviour in the other PR are more visible and easy to
review.

This adds tests for refreshes on collections for:
- list/set/map
- RPC/non-PRC
- null/empty/non-empty collections
- nil/non-nil cloud values for the nil collections
- top-level collections/nested collections
- Properties with a value override in Create/ ones without - this is a
behaviour observed in AWS and GCP labels and some other providers,
mainly seen around maps.

The goal of the tests is to:
- Ensure we do not regress on behaviour in PRC vs non-PRC
- Ensure we do not regress on behaviour in PRC as we change the
implementation in
#2073 /
#2065

I've flattened the matrix in order to allow us to annotate/skip
individual test cases.
  • Loading branch information
VenelinMartinov authored Jun 11, 2024
1 parent ed2a84b commit 388299d
Show file tree
Hide file tree
Showing 2 changed files with 701 additions and 2 deletions.
23 changes: 21 additions & 2 deletions pkg/tests/internal/pulcheck/pulcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,32 @@ type T interface {
pulumitest.PT
}

type bridgedProviderOpts struct {
DisablePlanResourceChange bool
}

// BridgedProviderOpts
type BridgedProviderOpt func(*bridgedProviderOpts)

// WithPlanResourceChange
func DisablePlanResourceChange() BridgedProviderOpt {
return func(o *bridgedProviderOpts) {
o.DisablePlanResourceChange = true
}
}

// This is an experimental API.
func BridgedProvider(t T, providerName string, resMap map[string]*schema.Resource) info.Provider {
func BridgedProvider(t T, providerName string, resMap map[string]*schema.Resource, opts ...BridgedProviderOpt) info.Provider {
options := &bridgedProviderOpts{}
for _, opt := range opts {
opt(options)
}

tfp := &schema.Provider{ResourcesMap: resMap}
EnsureProviderValid(t, tfp)

shimProvider := shimv2.NewProvider(tfp, shimv2.WithPlanResourceChange(
func(tfResourceType string) bool { return true },
func(tfResourceType string) bool { return !options.DisablePlanResourceChange },
))

provider := tfbridge.ProviderInfo{
Expand Down
Loading

0 comments on commit 388299d

Please sign in to comment.