Skip to content

Commit a057427

Browse files
committed
feat: add missing HAL docs for various relations and correct test that should have identified their absence
1 parent 02443f3 commit a057427

File tree

5 files changed

+42
-2
lines changed

5 files changed

+42
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Can I Deploy
2+
3+
Allowed methods: `GET`
4+
5+
A simplified resource that accepts the same parameters as the basic usage of the `can-i-deploy` CLI command.
6+
7+
**Parameters**:
8+
9+
* _pacticipant_: The name of the pacticipant (application) you want to deploy (required).
10+
* _version_: The version of the pacticipant (application) you want to deploy (required).
11+
* _to_: The tag used to identify the environment into which you wish to deploy the application (eg. `test` or `prod`). This assumes you have already tagged the currently deployed versions of each of the integrated applications with the same tag. To be specific, the logic checks if the application version you have specified is compatible with the latest versions _for the specified tag_ of all the other applications it is integrated with. This parameter is optional - if not specified, it checks for compatiblity with the latest version of all the integrated applications.
12+
13+
14+
If you have an environment that you identify with the tag `prod`, and each time you deployed an application to the prod environment you tagged the relevant application version in the Pact Broker with the tag `prod`, then calling `/can-i-deploy?pacticipant=Foo&version=734137278d&to=prod` will check that version 734137278d of Foo has a successful verification result with each of the integrated application versions that are currently in prod. That is, it is safe to deploy.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Pacticipant version tag
2+
3+
Allowed methods: `GET`, `PUT`, `DELETE`
4+
Path: `/pacticipants/{pacticipant}/versions/{version}/tags/{tag}`
5+
6+
To create a tag, send an empty request with the URL specified above and `Content-Type` of `application/json`.
7+
8+
Tags must be applied before pacts or verification results are published to ensure that the webhook fires with the correct metadata.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Matrix
2+
3+
Allowed methods: `GET`
4+
5+
This resource returns the "cartesian join" of every pact publication and every verification results publication, and is used to determine whether or not an application is safe to deploy.
6+
7+
If you need to use this API, consider calling the `/can-i-deploy` resource instead.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Metrics
2+
3+
Allowed methods: `GET`
4+
5+
Returns counts for the Pact Broker resources.

spec/lib/pact_broker/doc/coverage_spec.rb

+8-2
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,21 @@
1515

1616
let(:index_response) { get "/", {}, { 'HTTP_ACCEPT' => 'application/hal+json' } }
1717
let(:index_body) { JSON.parse(index_response.body) }
18+
let(:docs_missing_string) { "No documentation exists"}
19+
20+
it "returns a known message when the documentation doesn't exist" do
21+
get "/docs/does-not-exist?context=index", {}, { 'HTTP_ACCEPT' => 'text/html' }
22+
expect(last_response.body).to include docs_missing_string
23+
end
1824

1925
it "has a document for each relation" do
20-
relations_that_should_have_docs = index_body['_links'].keys - ['self', 'curies']
26+
relations_that_should_have_docs = index_body['_links'].keys - ['self', 'curies', 'beta:provider-pacts-for-verification']
2127
relations_without_docs = {}
2228

2329
relations_that_should_have_docs.each do | relation |
2430
path = "/docs/#{relation.split(":", 2).last}?context=index"
2531
get path, {}, { 'HTTP_ACCEPT' => 'text/html' }
26-
if last_response.status != 200
32+
if last_response.body.include?(docs_missing_string)
2733
relations_without_docs[relation] = last_response.status
2834
end
2935
end

0 commit comments

Comments
 (0)