Skip to content

Commit

Permalink
feat: allow disabling coloured output in Verifier
Browse files Browse the repository at this point in the history
  • Loading branch information
stan-is-hate committed Sep 22, 2023
1 parent b93338e commit 927d51a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func TestV3HTTPProvider(t *testing.T) {
return models.ProviderStateResponse{"uuid": "1234"}, nil
},
},
DisableColoredOutput: true,
})

assert.NoError(t, err)
Expand Down
5 changes: 5 additions & 0 deletions internal/native/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions provider/verify_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -261,6 +264,7 @@ func (v *VerifyRequest) validate(handle *native.Verifier) error {
}

handle.SetNoPactsIsError(v.FailIfNoPactsFound)
handle.SetColoredOutput(!v.DisableColoredOutput)

return nil
}
Expand Down

0 comments on commit 927d51a

Please sign in to comment.