Skip to content

Commit

Permalink
fix: fail if ProviderVersion not provided but BrokerURL is supplied
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Fellows committed Oct 18, 2019
1 parent f97b6bd commit cb2a377
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions types/verify_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ func (v *VerifyRequest) Validate() error {
v.Args = append(v.Args, "--broker-token", v.BrokerToken)
}

if v.BrokerURL != "" && v.ProviderVersion == "" {
return errors.New("both 'ProviderVersion' must be supplied if 'BrokerURL' given")
}

if v.ProviderVersion != "" {
v.Args = append(v.Args, "--provider_app_version", v.ProviderVersion)
}
Expand Down
16 changes: 16 additions & 0 deletions types/verify_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ func TestVerifyRequest_NoBaseURL(t *testing.T) {
}

func TestVerifyRequest_BrokerUsernameWithoutPassword(t *testing.T) {
r := VerifyRequest{
PactURLs: []string{"http://localhost:1234/path/to/pact"},
ProviderBaseURL: "http://localhost:8080",
BrokerURL: "http://localhost:1234",
ProviderVersion: "1.0.0.",
BrokerPassword: "1234",
}

err := r.Validate()

if err == nil {
t.Fatal("want error, got nil")
}
}

func TestVerifyRequest_BrokerURLWithoutVersion(t *testing.T) {
r := VerifyRequest{
PactURLs: []string{"http://localhost:1234/path/to/pact"},
ProviderBaseURL: "http://localhost:8080",
Expand Down

0 comments on commit cb2a377

Please sign in to comment.