From ba469d2967608e37a4883f620d7cf628fda3803f Mon Sep 17 00:00:00 2001 From: Thomas Kappler Date: Fri, 24 May 2024 12:25:38 +0200 Subject: [PATCH] Add unit test --- infer/resource_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/infer/resource_test.go b/infer/resource_test.go index 8cebcd2..37031fa 100644 --- a/infer/resource_test.go +++ b/infer/resource_test.go @@ -449,3 +449,18 @@ func TestHydrateFromState(t *testing.T) { }), )) } + +type inputForDefaultCheck struct { + P1 string `pulumi:"str,optional"` +} + +func (i *inputForDefaultCheck) Annotate(a Annotator) { + a.SetDefault(&i.P1, "default") +} + +func TestDefaultCheckAppliesDefaultValues(t *testing.T) { + input, failures, err := DefaultCheck[inputForDefaultCheck](nil) + require.NoError(t, err) + assert.Empty(t, failures) + assert.Equal(t, "default", input.P1) +}