From 4cd3727b9da93194e8848f340d599a519e002df1 Mon Sep 17 00:00:00 2001 From: Matt Fellows Date: Fri, 9 Dec 2022 23:19:24 +1100 Subject: [PATCH] chore: fix tests for logging --- message/v3/asynchronous_message.go | 1 + message/v4/asynchronous_message.go | 1 + message/v4/synchronous_message.go | 1 + provider/verify_request_test.go | 18 +++++++++++++----- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/message/v3/asynchronous_message.go b/message/v3/asynchronous_message.go index ebee4406a..45d30bcc2 100644 --- a/message/v3/asynchronous_message.go +++ b/message/v3/asynchronous_message.go @@ -11,6 +11,7 @@ import ( "github.com/pact-foundation/pact-go/v2/internal/native" mockserver "github.com/pact-foundation/pact-go/v2/internal/native" + logging "github.com/pact-foundation/pact-go/v2/log" "github.com/pact-foundation/pact-go/v2/models" ) diff --git a/message/v4/asynchronous_message.go b/message/v4/asynchronous_message.go index a8f3c21e0..603cc7c16 100644 --- a/message/v4/asynchronous_message.go +++ b/message/v4/asynchronous_message.go @@ -11,6 +11,7 @@ import ( "github.com/pact-foundation/pact-go/v2/internal/native" mockserver "github.com/pact-foundation/pact-go/v2/internal/native" + logging "github.com/pact-foundation/pact-go/v2/log" "github.com/pact-foundation/pact-go/v2/models" ) diff --git a/message/v4/synchronous_message.go b/message/v4/synchronous_message.go index a1c6aa9b1..e9323b7fe 100644 --- a/message/v4/synchronous_message.go +++ b/message/v4/synchronous_message.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/pact-foundation/pact-go/v2/internal/native" + logging "github.com/pact-foundation/pact-go/v2/log" "github.com/pact-foundation/pact-go/v2/models" ) diff --git a/provider/verify_request_test.go b/provider/verify_request_test.go index a5ffd03f7..0c13c5bbc 100644 --- a/provider/verify_request_test.go +++ b/provider/verify_request_test.go @@ -16,6 +16,7 @@ func TestVerifyRequestValidate(t *testing.T) { name string request *VerifyRequest err bool + panic bool }{ {name: "valid parameters", request: &VerifyRequest{ PactURLs: []string{"http://localhost:1234/path/to/pact"}, @@ -25,15 +26,21 @@ func TestVerifyRequestValidate(t *testing.T) { }, err: false}, {name: "no base URL provided", request: &VerifyRequest{ PactURLs: []string{"http://localhost:1234/path/to/pact"}, - }, err: true}, + }, err: true, panic: true}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - err := tt.request.validate(handle) - if tt.err { - assert.Error(t, err) + if tt.panic { + assert.Panics(t, (func() { + tt.request.validate(handle) + })) } else { - assert.NoError(t, err) + err := tt.request.validate(handle) + if tt.err { + assert.Error(t, err) + } else { + assert.NoError(t, err) + } } }) } @@ -55,6 +62,7 @@ func TestVerifyRequestValidate(t *testing.T) { }, err: true}, {name: "broker url without name/version", request: &VerifyRequest{ BrokerURL: "http://localhost:1234", + ProviderBaseURL: "http://localhost:8080", ProviderVersion: "1.0.0", BrokerPassword: "1234", }, err: true},