https://pulumi.com logo
Title
b

brash-gigabyte-81569

04/06/2023, 3:31 PM
I am looking to add test coverage to my custom provider created using the pulumi-provider-go, are there any examples of using the integration server to test component creation? I only see an example of testing function invocations here but not seeing how I would test a resource/component. Thanks.
l

limited-rainbow-51650

04/06/2023, 5:46 PM
Looping in @ancient-policeman-24615
a

ancient-policeman-24615

04/06/2023, 6:10 PM
To test a resource, I would use a life cycle test (example). Components only have the
Construct
function, so you can test them by calling
server.Construct
(here) instead of calling
server.Invoke
.
b

brash-gigabyte-81569

04/06/2023, 6:14 PM
I am struggling figuring out how to return a ConstructResponse from that
a

ancient-policeman-24615

04/06/2023, 6:15 PM
I’m not sure I understand. Do you have a branch/gist/code that I could look at?
b

brash-gigabyte-81569

04/06/2023, 6:17 PM
server := integration.NewServer("foo", semver.Version{Minor: 1}, provider())
	r, err := server.Construct(p.ConstructRequest{
		URN:     "urn:pulumi:dev::test::foo:bar:Bar::test",
		Preview: false,
		Construct: func(ctx p.Context, cf p.ConstructFunc) (p.ConstructResponse, error) {
			comp, err := cf(ctx, ComponentArgs{
				Fizz: "Buzz",
			})
			if err != nil {
				return nil, err
			}
			return ????, nil
		},
	})
^ that Construct function has a return of ConstructResponse and it isn’t clear how to get that from what I have
Perhaps you could provide an example using the RandomLogin here
a

ancient-policeman-24615

04/07/2023, 12:16 AM
I see the problem here. Its not possible to use
integration
with a component resources right now.
As a workaround, you could return a zero value of
p.ConstructResponse{}
and assert within the
p.ConstructRequest.Construct
function that
comp
has the desired output.
b

brash-gigabyte-81569

04/07/2023, 7:25 PM
Alright, thanks for checking into it