Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add better provider verification output #57

Merged
merged 1 commit into from
Nov 11, 2017

Conversation

bmarini
Copy link
Contributor

@bmarini bmarini commented Nov 9, 2017

This enables you to write your provider verification tests like this:

res, err := pact.VerifyProvider(types.VerifyRequest{
	ProviderBaseURL: "baseurl",
	PactURLs:        []string{"url1.json","url2.json"},
})
if err != nil {
	t.Fatal(err)
}
for _, ex := range res.Examples {
	if ex.Status != "passed" {
		t.Errorf("%s\n%s\n", ex.FullDescription, ex.Exception.Message)
	}
}

Changes

The main change is to func (p PactClient) VerifyProvider(request types.VerifyRequest, reply *types.ProviderVerifierResponse) error. The reply type is specific to the JSON output of the pact-provider-verifier binary. Also, I've changed the semantics of the error a bit. If a valid JSON response from the binary can be parsed, there will be no error. Otherwise, there will be an error, and it will include both stderr and stdout from the binary.

Notes

In doing this, I realized it would be pretty easy to repurpose the daemon package to remove the rpc layer and use it directly to execute the external ruby binaries. That could be a first step in solving #31

@bmarini
Copy link
Contributor Author

bmarini commented Nov 9, 2017

I'll be sure to update docs and examples and readme if these changes are given the green light.

BREAKING CHANGE: PactClient#VerifyProvider now returns a
types.ProviderVerifierResponse as well as an error. An error
means that the client was unable to run the verification code
successfully. The ProviderVerifierResponse is a direct mapping
of the json output returned by the pact-provider-verifier binary.
Iterate over the Examples structs to determine if they passed.

NOTE: Verbose output for the types.VerifyRequest is not compatible
with the json format since it logs to stdout, causing the json to
be unparsable.
t.Errorf("%s\n%s\n", example.FullDescription, example.Exception.Message)
}
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This func is the only real addition for all these example tests. Everything else was just converting spaces to tabs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - weird I never picked this up!

@mefellows
Copy link
Member

This looks great, I'll review today!

@mefellows
Copy link
Member

In doing this, I realized it would be pretty easy to repurpose the daemon package to remove the rpc layer and use it directly to execute the external ruby binaries. That could be a first step in solving #31

Yep, the benefit of the current daemon approach is that the pact binaries are known to be co-located with the daemon. The challenges with removing the daemon, is that we need another way of getting the pact binaries onto the PATH, and then keeping them up to date. But agreed, it is the first step (FWIW this was always the plan).

@mefellows mefellows merged commit e718293 into pact-foundation:master Nov 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants