From e89585e8d115c4ce7ffa66f3b9e29bbf7c6a3e81 Mon Sep 17 00:00:00 2001 From: Timothy Jones Date: Mon, 1 May 2017 17:46:13 +1000 Subject: [PATCH] fix(verify) prevent crash when calling VerifyProvider() Closes #24 --- dsl/pact.go | 5 +++-- dsl/pact_test.go | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dsl/pact.go b/dsl/pact.go index ee9566f88..1a2f17714 100644 --- a/dsl/pact.go +++ b/dsl/pact.go @@ -101,6 +101,9 @@ func (p *Pact) Setup(startMockServer bool) *Pact { p.SpecificationVersion = 2 } + client := &PactClient{Port: p.Port, Network: p.Network, Address: p.Host} + p.pactClient = client + if p.Server == nil && startMockServer { args := []string{ "--pact-specification-version", @@ -114,8 +117,6 @@ func (p *Pact) Setup(startMockServer bool) *Pact { "--provider", p.Provider, } - client := &PactClient{Port: p.Port, Network: p.Network, Address: p.Host} - p.pactClient = client p.Server = client.StartServer(args) } diff --git a/dsl/pact_test.go b/dsl/pact_test.go index b4f951f6c..9749355e8 100644 --- a/dsl/pact_test.go +++ b/dsl/pact_test.go @@ -182,6 +182,9 @@ func TestPact_Setup(t *testing.T) { if pact.Server != nil { t.Fatalf("Expected server to be nil") } + if pact.pactClient == nil { + t.Fatalf("Needed to still have a client") + } } func TestPact_Teardown(t *testing.T) {