From 927d51a87322602c6b7b243c44e6742b2e852e43 Mon Sep 17 00:00:00 2001 From: Stanislav Vodetskyi Date: Mon, 18 Sep 2023 14:53:47 -0700 Subject: [PATCH] feat: allow disabling coloured output in Verifier --- examples/provider_test.go | 1 + internal/native/verifier.go | 5 +++++ provider/verify_request.go | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/examples/provider_test.go b/examples/provider_test.go index 909e5eb18..852cfd411 100644 --- a/examples/provider_test.go +++ b/examples/provider_test.go @@ -92,6 +92,7 @@ func TestV3HTTPProvider(t *testing.T) { return models.ProviderStateResponse{"uuid": "1234"}, nil }, }, + DisableColoredOutput: true, }) assert.NoError(t, err) diff --git a/internal/native/verifier.go b/internal/native/verifier.go index 012c62824..ae781840a 100644 --- a/internal/native/verifier.go +++ b/internal/native/verifier.go @@ -32,6 +32,7 @@ void pactffi_verifier_broker_source_with_selectors(VerifierHandle *handle, const int pactffi_verifier_execute(VerifierHandle *handle); void pactffi_verifier_add_provider_transport(VerifierHandle *handle, const char *protocol, uint32_t port, const char *path, const char *scheme); void pactffi_verifier_set_no_pacts_is_error(VerifierHandle *handle, bool is_error); +int pactffi_verifier_set_coloured_output(struct VerifierHandle *handle, bool coloured_output); */ import "C" @@ -247,6 +248,10 @@ func (v *Verifier) SetNoPactsIsError(isError bool) { C.pactffi_verifier_set_no_pacts_is_error(v.handle, boolToCInt(isError)) } +func (v *Verifier) SetColoredOutput(isColoredOutput bool) { + C.pactffi_verifier_set_coloured_output(v.handle, boolToCInt(isColoredOutput)) +} + func stringArrayToCStringArray(inputs []string) **C.char { if len(inputs) == 0 { return nil diff --git a/provider/verify_request.go b/provider/verify_request.go index 36b33d633..c2ba9acb7 100644 --- a/provider/verify_request.go +++ b/provider/verify_request.go @@ -164,6 +164,9 @@ type VerifyRequest struct { // Disable SSL verification for HTTP requests DisableSSLVerification bool + + // If true, will disable colored output in console. + DisableColoredOutput bool } // Validate checks that the minimum fields are provided. @@ -261,6 +264,7 @@ func (v *VerifyRequest) validate(handle *native.Verifier) error { } handle.SetNoPactsIsError(v.FailIfNoPactsFound) + handle.SetColoredOutput(!v.DisableColoredOutput) return nil }