Skip to content

Commit

Permalink
feat(proxy): cleanup verifier interface
Browse files Browse the repository at this point in the history
- Update TS version
- Cleanup of Verifier interface
- Add tests for Verifier
- Move the HTTP Pact related code into it's own module
- Main pact interface is now purely interface
  • Loading branch information
mefellows committed Feb 20, 2019
1 parent d3954e1 commit 63a661b
Show file tree
Hide file tree
Showing 14 changed files with 602 additions and 360 deletions.
59 changes: 29 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,41 @@
language: node_js
node_js:
- '6'
- '7'
- '8'
- '9'
- '10'
- "6"
- "7"
- "8"
- "9"
- "10"
os:
- linux
# - osx
- linux
matrix:
fast_finish: true
env:
matrix:
- CXX=g++-4.8
- CXX=g++-4.8
global:
# travis encrypt NPM_KEY=<key>
- secure: "dadftjIY7w+KRucMDOqflXYTvWI1WYvtLtvGnbJuoFrgviax5zhwI7rSi6PTvW7mqV05FtqfVVb8Mgkwp1GNhv9byzuPCKnX6zN/tnl3mC++ivMA3BI7KhNp6VinzVeHWN+9BSYAQs1RQbslIK6IJ3oQJ9azp1MnxMQ1s0w5hqo0ojPWRJsm/IN57/pSiR4U0yyvONdwVg7Q8RQmyMZtovA2QzrR3ij6IxBwiJ7RQXsWIYkPL1SzaIqNNhMOdXK3m1iCESmtNc1BG9oEoaZc0ZzowT/O5VVPWe+bUfdSaAHjkTauaMCU2OAk6J89yd7pSCT5fe1YYYPgTIZiPkG0wQH8k7dKqqeaxBo+tN7uCfkYlTMNZmjv+qVBafoP8wBV97g3UugDqqIXaFknTUDnSNaigcJjFRWhCHBtltR+hzF6pCl3H1o1dDnmJWrgEb01qJ0lZonmaK/anZGNpUWE6qndOKBwnd0XiR1LnvzL/7tdflNb4DPy+lWdDEj4HWZR3lFA009m651qHBN+117ousZFXJ1866JywkAM2GrEWD4umzKknXDhulMG/Q32DS01BgW1pMenzQkH5WE+O0T3W/8BPw0Ev//bqZIg0gDckppUexHZ+pMhAFMaJfCzYVhrA0fhwLb+1EW7VDEcQIc0QHGXOb3Vclja7qB4yDuAJxk="
# travis encrypt NPM_KEY=<key>
- secure: "dadftjIY7w+KRucMDOqflXYTvWI1WYvtLtvGnbJuoFrgviax5zhwI7rSi6PTvW7mqV05FtqfVVb8Mgkwp1GNhv9byzuPCKnX6zN/tnl3mC++ivMA3BI7KhNp6VinzVeHWN+9BSYAQs1RQbslIK6IJ3oQJ9azp1MnxMQ1s0w5hqo0ojPWRJsm/IN57/pSiR4U0yyvONdwVg7Q8RQmyMZtovA2QzrR3ij6IxBwiJ7RQXsWIYkPL1SzaIqNNhMOdXK3m1iCESmtNc1BG9oEoaZc0ZzowT/O5VVPWe+bUfdSaAHjkTauaMCU2OAk6J89yd7pSCT5fe1YYYPgTIZiPkG0wQH8k7dKqqeaxBo+tN7uCfkYlTMNZmjv+qVBafoP8wBV97g3UugDqqIXaFknTUDnSNaigcJjFRWhCHBtltR+hzF6pCl3H1o1dDnmJWrgEb01qJ0lZonmaK/anZGNpUWE6qndOKBwnd0XiR1LnvzL/7tdflNb4DPy+lWdDEj4HWZR3lFA009m651qHBN+117ousZFXJ1866JywkAM2GrEWD4umzKknXDhulMG/Q32DS01BgW1pMenzQkH5WE+O0T3W/8BPw0Ev//bqZIg0gDckppUexHZ+pMhAFMaJfCzYVhrA0fhwLb+1EW7VDEcQIc0QHGXOb3Vclja7qB4yDuAJxk="
script: ./scripts/build.sh
after_success:
- npm run coverage
- npm run coverage
before_deploy:
- npm prune --production
- tar -czvf pactjs.tar.gz config dist src package.json README.md LICENSE
- npm run deploy:prepare
- npm prune --production
- tar -czvf pactjs.tar.gz config dist src package.json README.md LICENSE
- npm run deploy:prepare
deploy:
- provider: releases
api_key:
secure: FmoLJnO8GNxyztR2P433ZCumYPrxiZdBCfVhmhTGYlXhOfVaAECm0gUVPLZuBQRUaqsef5ekg+OSIA5xbrnNoOQ9qlmnF2n+5yiwqG6o35XLA4L6lB5pL+x8xoAAgpaj9dTD184HKGdub3heQStTPRd2ll3nNRwxhfyIyBaMX3elDTH3mkV2QxNhG1RTgJe322PQrwoU2sWkghTWNr4t+h/G+oYu364xwZuxFX1hrFpAW+IEmbDSuhmCe24lMU96ntIiciRU3eBYR7s3KlktOFgMORXMRw3H/qaGmx7rKtpJ892XGRuVbw+tPB3A1jbFvOwJwzpnsWG5REu3PkZ6oiWpnX+5riN3jPyvFpWd+LLfH1KdZeBnF/anEfl+mSPdrDROOWotV3Xt5zOiEwx2j4BRbDNfa6wXzX0zK31AMf0IFmw7KZJkzcyWjNRluxTn3r2bbjNoi+gBojQuX27R3AQz5G0E0yZUk5ujmcd+85WOgNh/zVwsZLHYVQxDyULkbDTCDAulBsJLyxUFRs0JixyHCvA6srrUdpcO0NdyDfvULk9e/g/c9aD56Rk4xT4/Xa7K1fAHLjLkV6CA4H9Of96Zl2BK8r6LAlw382hO7FaZH+A3YShObEeTiZsDbfSQrFl5x8aimvc9oeYopvvQ+EdZxHvvwxHQIp/MWOybdJ4=
file: pactjs.tar.gz
skip_cleanup: true
on:
tags: true
branch: feat/message-pact
node: '8'
- provider: script
skip_cleanup: true
script: ./scripts/publish.sh
on:
tags: true
branch: feat/message-pact
node: '8'
- provider: releases
api_key:
secure: FmoLJnO8GNxyztR2P433ZCumYPrxiZdBCfVhmhTGYlXhOfVaAECm0gUVPLZuBQRUaqsef5ekg+OSIA5xbrnNoOQ9qlmnF2n+5yiwqG6o35XLA4L6lB5pL+x8xoAAgpaj9dTD184HKGdub3heQStTPRd2ll3nNRwxhfyIyBaMX3elDTH3mkV2QxNhG1RTgJe322PQrwoU2sWkghTWNr4t+h/G+oYu364xwZuxFX1hrFpAW+IEmbDSuhmCe24lMU96ntIiciRU3eBYR7s3KlktOFgMORXMRw3H/qaGmx7rKtpJ892XGRuVbw+tPB3A1jbFvOwJwzpnsWG5REu3PkZ6oiWpnX+5riN3jPyvFpWd+LLfH1KdZeBnF/anEfl+mSPdrDROOWotV3Xt5zOiEwx2j4BRbDNfa6wXzX0zK31AMf0IFmw7KZJkzcyWjNRluxTn3r2bbjNoi+gBojQuX27R3AQz5G0E0yZUk5ujmcd+85WOgNh/zVwsZLHYVQxDyULkbDTCDAulBsJLyxUFRs0JixyHCvA6srrUdpcO0NdyDfvULk9e/g/c9aD56Rk4xT4/Xa7K1fAHLjLkV6CA4H9Of96Zl2BK8r6LAlw382hO7FaZH+A3YShObEeTiZsDbfSQrFl5x8aimvc9oeYopvvQ+EdZxHvvwxHQIp/MWOybdJ4=
file: pactjs.tar.gz
skip_cleanup: true
on:
tags: true
branch: master
node: "8"
- provider: script
skip_cleanup: true
script: ./scripts/publish.sh
on:
tags: true
branch: master
node: "8"
2 changes: 1 addition & 1 deletion examples/e2e/test/provider.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe("Pact Verification", () => {
// customProviderHeaders: ['Authorization: basic e5e5e5e5e5e5e5']
}

return new Verifier().verifyProvider().then(output => {
return new Verifier().verifyProvider(opts).then(output => {
console.log("Pact Verification Complete!")
console.log(output)
})
Expand Down
96 changes: 51 additions & 45 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
"@types/node": "^8.0.24",
"@types/proxyquire": "^1.3.27",
"@types/q": "^1.0.6",
"@types/sinon": "^2.3.3",
"@types/sinon": "^7.0.6",
"@types/sinon-chai": "^2.7.29",
"@types/superagent": "^3.5.7",
"@types/tough-cookie": "^2.3.2",
Expand Down Expand Up @@ -150,7 +150,7 @@
"nyc": "^13.1.0",
"proxyquire": "^2.0.1",
"rimraf": "^2.6.2",
"sinon": "^6.3.5",
"sinon": "^7.2.4",
"sinon-chai": "^2.13.0",
"source-map-loader": "^0.2.1",
"source-map-support": "^0.4.18",
Expand Down
35 changes: 31 additions & 4 deletions src/dsl/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { MatcherResult } from "./matchers"

/**
* Metadata is a map containing message context,
* such as content-type etc.
* such as content-type, correlation IDs etc.
*
* @module Message
*/
Expand All @@ -12,7 +12,6 @@ export interface Metadata {

/**
* A Message is an asynchronous Interaction, sent via a Provider
* (consumer in the http, synchronous interaction parlance)
*
* @module Message
*/
Expand All @@ -23,12 +22,40 @@ export interface Message {
contents: any
}

// Message producer/handlers
/**
* A Message Descriptor is a set of additional context for a given message
*
* @module Message
*/
export interface MessageDescriptor {
providerStates?: [{ name: string }]
description: string
metadata?: Metadata
}

/**
* A Message Consumer is a function that will receive a message
* from a given Message Provider. It is given the full Message
* context during verification.
*
* @module Message
*/
export type MessageConsumer = (m: Message) => Promise<any>
export type MessageProvider = (m: Message) => Promise<any>

/**
* A Message Provider is a function that will be invoked by the framework
* in order to _produce_ a message for a consumer. The response must match what
* the given consumer has specified in the pact file. It is given a Message
* Descriptor object when being invoked which can be used for additional context.
*
* @module Message
*/
export type MessageProvider = (m: MessageDescriptor) => Promise<any>

export interface MessageProviders {
[name: string]: MessageProvider
}

export interface StateHandlers {
[name: string]: (state: string) => Promise<any>
}
1 change: 1 addition & 0 deletions src/dsl/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export interface MessageProviderOptions {
tags?: string[]
timeout?: number
}

export interface MessageConsumerOptions {
// The name of the consumer
consumer: string
Expand Down
Loading

0 comments on commit 63a661b

Please sign in to comment.