Skip to content

Commit

Permalink
Refactor sdkv2 detailed diff tests (#2816)
Browse files Browse the repository at this point in the history
This PR refactors the SDKv2 detailed diff tests to make test sharding
easier. The main problem was that TestDetailedDiffSet was too large.
Very similar to what
#2814 does for PF.

This PR:
- Moves the SDKv2 detailed diff tests to their own folder. This should
make sharing code between them easier without exposing it to the other
tests.
- Splits up `TestDetailedDiffSet` into a few separate tests. This will
allow the tests to be run on different shards.
- Moves around some of the shared code into the `value_makers.go` file,
instead of duplicating in each test.
- Renames the tests to specify that they are for SDKv2 and renamed some
of the utility functions to clarify what they do.


[2c18440](2c18440)
has test recordings, the rest are the changes. The test recording
changes are all no-ops related to the change in the struct being
recorded.
  • Loading branch information
VenelinMartinov authored Jan 14, 2025
1 parent 7bfd76b commit f68bff0
Show file tree
Hide file tree
Showing 1,016 changed files with 1,510 additions and 3,050 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
crosstests "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/internal/tests/cross-tests"
)

func TestDetailedDiffList(t *testing.T) {
func TestSDKv2DetailedDiffList(t *testing.T) {
t.Parallel()

listAttrSchema := schema.Resource{
Expand Down Expand Up @@ -297,14 +297,6 @@ func TestDetailedDiffList(t *testing.T) {

scenarios := append(oneElementScenarios, multiElementScenarios...)

type testOutput struct {
initialValue *[]string
changeValue *[]string
tfOut string
pulumiOut string
detailedDiff map[string]any
}

runTest := func(t *testing.T, schema schema.Resource, valueMaker func(*[]string) map[string]cty.Value, initialValue *[]string, changeValue *[]string) {
diff := crosstests.Diff(t, &schema, valueMaker(initialValue), valueMaker(changeValue))
autogold.ExpectFile(t, testOutput{
Expand Down
Loading

0 comments on commit f68bff0

Please sign in to comment.