pulumi/providertest

Replay framework does not detect diffs with empty arrays

Closed this issue · 2 comments

What happened?

I noticed that a test in the bridge was passing both with an empty array property specified and without it.

This means that one of the two is not compared properly.

Example

in the bridge, provider_test.go, while working on pulumi/pulumi-terraform-bridge#1725:

func TestMinMaxItemsOneOptional(t *testing.T) {
	p := &schemav2.Provider{
		Schema: map[string]*schemav2.Schema{},
		ResourcesMap: map[string]*schemav2.Resource{
			"res": {
				Schema: map[string]*schemav2.Schema{
					"max_items_one_prop": &schema.Schema{
						Type:     schema.TypeSet,
						Optional: true,
						MaxItems: 1,
						MinItems: 1,
						Elem:     &schemav2.Schema{Type: schemav2.TypeString},
					},
				},
			},
		},
	}
	shimProv := shimv2.NewProvider(p)
	provider := &Provider{
		tf:     shimProv,
		config: shimv2.NewSchemaMap(p.Schema),
		info: ProviderInfo{
			P: shimProv,
		},
		resources: map[tokens.Type]Resource{
			"Res": {
				TF:     shimv2.NewResource(p.ResourcesMap["res"]),
				TFName: "res",
				Schema: &ResourceInfo{},
			},
		},
	}
	t.Run("No diff when updating after create when prop not specified", func(t *testing.T) {
		testutils.ReplaySequence(t, provider, `[
			{
				"method": "/pulumirpc.ResourceProvider/Create",
				"request": {
				  "urn": "urn:pulumi:dev::teststack::Res::exres",
				  "properties": {
					"__defaults": [],
					"maxItemsOneProp": null
				  },
				  "preview": true
				},
				"response": {
				  "properties": {
					"id": "",
					"maxItemsOneProp": []
				  }
				}
			}
		  ]
		`)
	})
}

This passes both with "maxItemsOneProp": [] in the response and without it.

Output of pulumi about

.

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

I can no longer repro this...

EDIT: I think I may have been editing the inputs, the hazards of doing finicky work in the evenings.

Cannot close issue:

  • does not have required labels: resolution/

Please fix these problems and try again.