forked from pact-foundation/pact-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(messages): implement initial producer and consumer interfaces
- Loading branch information
Showing
19 changed files
with
577 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,8 @@ _* | |
pact-go | ||
pacts | ||
logs | ||
log | ||
tmp | ||
|
||
# IDE | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package client | ||
|
||
import ( | ||
"log" | ||
) | ||
|
||
// MessageVerificationService is a wrapper for the Pact Provider Verifier Service. | ||
type MessageVerificationService struct { | ||
ServiceManager | ||
} | ||
|
||
// NewService creates a new MessageVerificationService with default settings. | ||
// Named Arguments allowed: | ||
// --consumer | ||
// --provider | ||
// --pact-dir | ||
func (v *MessageVerificationService) NewService(args []string) Service { | ||
v.Args = args | ||
// Currently has an issue, see https://travis-ci.org/pact-foundation/pact-message-ruby/builds/357675751 | ||
// v.Args = []string{"update", `{ "description": "a test mesage", "content": { "name": "Mary" } }`, "--consumer", "from", "--provider", "golang", "--pact-dir", "/tmp"} | ||
|
||
log.Printf("[DEBUG] starting message service with args: %v\n", v.Args) | ||
v.Cmd = "pact-message" | ||
|
||
return v | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package dsl | ||
|
||
// Message is a representation of a single, unidirectional message | ||
// e.g. MQ, pub/sub, Websocket, Lambda | ||
// Message is the main implementation of the Pact Message interface. | ||
type Message struct { | ||
// Message Body | ||
Content interface{} `json:"content,omitempty"` | ||
|
||
// Provider state to be written into the Pact file | ||
State string `json:"providerState,omitempty"` | ||
|
||
// Message metadata | ||
Metadata MapMatcher `json:"metadata,omitempty"` | ||
|
||
// Description to be written into the Pact file | ||
Description string `json:"description"` | ||
|
||
Args []string `json:"-"` | ||
} | ||
|
||
// Given specifies a provider state. Optional. | ||
func (p *Message) Given(state string) *Message { | ||
p.State = state | ||
return p | ||
} | ||
|
||
// ExpectsToReceive specifies the content it is expecting to be | ||
// given from the Provider. The function must be able to handle this | ||
// message for the interaction to succeed. | ||
func (p *Message) ExpectsToReceive(description string) *Message { | ||
p.Description = description | ||
return p | ||
} | ||
|
||
// WithMetadata specifies message-implementation specific metadata | ||
// to go with the content | ||
func (p *Message) WithMetadata(metadata MapMatcher) *Message { | ||
p.Metadata = metadata | ||
return p | ||
} | ||
|
||
// WithContent specifies the details of the HTTP request that will be used to | ||
// confirm that the Provider provides an API listening on the given interface. | ||
// Mandatory. | ||
func (p *Message) WithContent(content interface{}) *Message { | ||
p.Content = toObject(content) | ||
|
||
return p | ||
} |
Oops, something went wrong.