diff --git a/dsl/client.go b/dsl/client.go index e1b4e9947..13bcdb412 100644 --- a/dsl/client.go +++ b/dsl/client.go @@ -226,7 +226,6 @@ func (p *PactClient) VerifyProvider(request types.VerifyRequest) ([]types.Provid err = cmd.Wait() wg.Wait() - var verification types.ProviderVerifierResponse for _, v := range verifications { v = strings.TrimSpace(v) @@ -235,6 +234,7 @@ func (p *PactClient) VerifyProvider(request types.VerifyRequest) ([]types.Provid // logging to stdout breaks the JSON response // https://github.com/pact-foundation/pact-ruby/commit/06fa61581512ba5570c315d089f2c0fc23c8cb11 if v != "" && strings.Index(v, "INFO") != 0 { + var verification types.ProviderVerifierResponse dErr := json.Unmarshal([]byte(v), &verification) response = append(response, verification) diff --git a/dsl/client_test.go b/dsl/client_test.go index 63ee8d7a8..a2986cc0d 100644 --- a/dsl/client_test.go +++ b/dsl/client_test.go @@ -76,11 +76,31 @@ func TestClient_VerifyProvider(t *testing.T) { BrokerPassword: "foo", ProviderStatesSetupURL: "http://foo/states/setup", } - _, err := client.VerifyProvider(req) + responses, err := client.VerifyProvider(req) if err != nil { t.Fatal("Error: ", err) } + + if len(responses) != 2 { + t.Fatalf("Expected 2 ProviderVerifierResponse objects but got %d", len(responses)) + } + + if len(responses[0].Examples) != 1 { + t.Fatalf("Expected responses[0] to have 1 example but got %d", len(responses[0].Examples)) + } + + if responses[0].Examples[0].ID != "1" { + t.Fatalf("Expected responses[0].Examples[0] to have id 1 but got %s", responses[0].Examples[0].ID) + } + + if len(responses[1].Examples) != 1 { + t.Fatalf("Expected responses[1] to have 1 example but got %d", len(responses[1].Examples)) + } + + if responses[1].Examples[0].ID != "2" { + t.Fatalf("Expected responses[1].Examples[0] to have id 2 but got %s", responses[1].Examples[0].ID) + } } func TestClient_VerifyProviderFailValidation(t *testing.T) { @@ -241,7 +261,7 @@ func TestHelperProcess(t *testing.T) { } // Success :) - fmt.Fprintf(os.Stdout, "{\"summary_line\":\"1 examples, 0 failures\"}\n{\"summary_line\":\"1 examples, 0 failures\"}") + fmt.Fprintf(os.Stdout, "{\"examples\":[{\"id\":\"1\"}],\"summary_line\":\"1 examples, 0 failures\"}\n{\"examples\":[{\"id\":\"2\"}],\"summary_line\":\"1 examples, 0 failures\"}") os.Exit(0) }