Skip to content

Commit

Permalink
fix: allow provider log level to be set/logged to file
Browse files Browse the repository at this point in the history
  • Loading branch information
mefellows committed Dec 20, 2021
1 parent 138ed97 commit 5160a01
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dsl/pact.go
Expand Up @@ -689,6 +689,8 @@ func (p *Pact) VerifyMessageProviderRaw(request VerifyMessageRequest) ([]types.P
ProviderVersion: request.ProviderVersion,
ProviderTags: request.ProviderTags,
Provider: p.Provider,
PactLogDir: p.LogDir,
PactLogLevel: p.LogLevel,
}

mux.HandleFunc("/", messageVerificationHandler(request.MessageHandlers, request.StateHandlers))
Expand Down
17 changes: 17 additions & 0 deletions dsl/verify_mesage_request.go
Expand Up @@ -51,6 +51,15 @@ type VerifyMessageRequest struct {
// verification step.
StateHandlers StateHandlers

// Specify an output directory to log all of the verification request/responses
// seen by the verification process. Useful to debug issues with your contract
// and API
PactLogDir string

// Specify the log verbosity of the CLI verifier process spawned through verification
// Useful for debugging issues with the framework itself
PactLogLevel string

// Arguments to the VerificationProvider
// Deprecated: This will be deleted after the native library replaces Ruby deps.
Args []string
Expand Down Expand Up @@ -86,5 +95,13 @@ func (v *VerifyMessageRequest) Validate() error {
v.Args = append(v.Args, "--publish_verification_results", "true")
}

if v.PactLogDir != "" {
v.Args = append(v.Args, "--log-dir", v.PactLogDir)
}

if v.PactLogLevel != "" {
v.Args = append(v.Args, "--log-level", v.PactLogLevel)
}

return nil
}
3 changes: 3 additions & 0 deletions examples/messages/provider/message_pact_provider_test.go
Expand Up @@ -62,6 +62,8 @@ func TestExampleMessageProvider_Success(t *testing.T) {
PactURLs: []string{filepath.ToSlash(fmt.Sprintf("%s/pactgomessageconsumer-pactgomessageprovider.json", pactDir))},
MessageHandlers: functionMappings,
StateHandlers: stateMappings,
PactLogDir: filepath.ToSlash(fmt.Sprintf("%s/logs", pactDir)),
PactLogLevel: "DEBUG",
})
}

Expand All @@ -75,5 +77,6 @@ func createPact() dsl.Pact {
return dsl.Pact{
Provider: "PactGoMessageProvider",
LogDir: logDir,
LogLevel: "DEBUG",
}
}

0 comments on commit 5160a01

Please sign in to comment.