pulumi/pkg/codegen/testing/test
Guinevere Saenger de0dcbfec6
[codegen/go] Update Go SDK function output to check for errors (#9274)
* [codegen/go] Update Go SDK function output to check for errors

Fixes https://github.com/pulumi/pulumi-aws/issues/1872.

This should result in the following sample output in the Go SDK:

```
func GetPolicyDocumentOutput(ctx *pulumi.Context, args GetPolicyDocumentOutputArgs, opts ...pulumi.InvokeOption) GetPolicyDocumentResultOutput {
	return pulumi.ToOutputWithContext(context.Background(), args).
		ApplyT(func(v interface{}) (GetPolicyDocumentResult, error) {
			args := v.(GetPolicyDocumentArgs)
			r, err := GetPolicyDocument(ctx, &args, opts...)
			if err != nil {
				return nil, err
			}
			if r == nil {
				return nil, fmt.Errorf("expected either result or error to be nil, not both")
			}
			return *r, err
		}).(GetPolicyDocumentResultOutput)
}
```

* Fix generated code panic on *nil (#9284)

* [codegen/go] Update Go SDK function output to check for errors

Fixes https://github.com/pulumi/pulumi-aws/issues/1872.

This should result in the following sample output in the Go SDK:

```
func GetPolicyDocumentOutput(ctx *pulumi.Context, args GetPolicyDocumentOutputArgs, opts ...pulumi.InvokeOption) GetPolicyDocumentResultOutput {
	return pulumi.ToOutputWithContext(context.Background(), args).
		ApplyT(func(v interface{}) (GetPolicyDocumentResult, error) {
			args := v.(GetPolicyDocumentArgs)
			r, err := GetPolicyDocument(ctx, &args, opts...)
			if r != nil {
				s = *r
			}
			return s, err
		}).(GetPolicyDocumentResultOutput)
}
```

* Alternate fix to safeguard dereferencing nil

* Accept codegen changes in the test suite

Co-authored-by: Guinevere Saenger <guinevere@pulumi.com>

* Update CHANGELOG_PENDING.md

Co-authored-by: Anton Tayanovskyy <anton@pulumi.com>
2022-03-24 20:11:53 -07:00
..
testdata [codegen/go] Update Go SDK function output to check for errors (#9274) 2022-03-24 20:11:53 -07:00
helpers.go PCL: Use resource aliases when resolving a type (#9238) 2022-03-18 11:48:39 -07:00
program_driver.go PCL: Use resource aliases when resolving a type (#9238) 2022-03-18 11:48:39 -07:00
sdk_driver.go [codegen/go] Add support for specifying internal dependencies (#9183) 2022-03-18 17:02:33 -07:00
type_driver.go ci: radical idea - what if slow tests & no stdout makes GH consider runner dead? 2022-03-06 14:52:13 -08:00