https://github.com/mefellows/pact-matt-plugin
Pact plugin for the MATT protocol (example project)
https://github.com/mefellows/pact-matt-plugin
pact plugin
Last synced: 10 months ago
JSON representation
Pact plugin for the MATT protocol (example project)
- Host: GitHub
- URL: https://github.com/mefellows/pact-matt-plugin
- Owner: mefellows
- License: mit
- Created: 2022-10-27T22:20:40.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-02-09T05:41:05.000Z (over 2 years ago)
- Last Synced: 2025-02-17T04:26:15.443Z (over 1 year ago)
- Topics: pact, plugin
- Language: C
- Homepage:
- Size: 8.36 MB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Pact Plugin Example - The MATT protocol
This is an example [plugin](https://github.com/pact-foundation/pact-plugins) for the [Pact](http://docs.pact.io) framework.
It implements a custom [Protocol](https://github.com/pact-foundation/pact-plugins/blob/main/docs/protocol-plugin-design.md) and [Content Matcher](https://github.com/pact-foundation/pact-plugins/blob/main/docs/content-matcher-design.md) for a fictional protocol - the MATT protocol.
## Install
```
pact-plugin-cli -y install https://github.com/mefellows/pact-matt-plugin/releases/tag/v0.0.1
```
## Writing tests
### Synchronous Messages
Set the request/response all in one go:
```
mattMessage := `{"request": {"body": "hellotcp"}, "response":{"body":"tcpworld"}}`
```
### HTTP
Separate out the body on the request/response part of the interaction:
```
mattRequest := `{"request": {"body": "hello"}}`
mattResponse := `{"response":{"body":"world"}}`
```
## Use Case
The MATT protocol is a simple text-based protocol, designed for efficient communication of messages to a Matt.
MATT messages are composed of basic text values, where the start and end of the communication must contain the word "MATT".
i.e. `MATTMATT`
in BNF it would be something like this:
```
::=
::= "MATT"
::= |
::= | |
::= "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"
::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
::= "|" | " " | "!" | "#" | "$" | "%" | "&" | "(" | ")" | "*" | "+" | "," | "-" | "." | "/" | ":" | ";" | ">" | "=" | "<" | "?" | "@" | "[" | "\" | "]" | "^" | "_" | "`" | "{" | "}" | "~"
```
When sent over TCP, messages are terminated with the newline delimeter `\n`.
## Developing the plugin
### Build and install the plugin
The following command will build the plugin, and install into the correct plugin directory for local development:
```
make install_local
```
### Regenerating the plugin protobuf definitions
If a new protobuf definition is required, copy into the `io_pact_plugin` folder and run the following Make task:
```
make proto
```
### Prerequsites
The protoc compiler must be installed for this plugin