I am looking to add test coverage to my custom pro...
# contribute
b
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
Looping in @ancient-policeman-24615
a
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
I am struggling figuring out how to return a ConstructResponse from that
a
I’m not sure I understand. Do you have a branch/gist/code that I could look at?
b
Copy code
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
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
Alright, thanks for checking into it