-
-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support deleting branch versions (removing a version from a bra…
…nch)
- Loading branch information
Showing
5 changed files
with
62 additions
and
3 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
15 changes: 13 additions & 2 deletions
15
lib/pact_broker/doc/views/index/pacticipant-branch-version.markdown
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 |
---|---|---|
@@ -1,14 +1,25 @@ | ||
# Pacticipant branch version | ||
|
||
Allowed methods: `GET`, `PUT` | ||
Allowed methods: `GET`, `PUT`, `DELETE` | ||
|
||
Path: `/pacticipants/{pacticipant}/branches/{branch}/versions/{version}` | ||
|
||
Get or add/create a pacticipant version for a branch. | ||
|
||
## Example | ||
## Create | ||
|
||
### Example | ||
|
||
Add a version to a branch. The pacticipant and branch are automatically created if they do not exist. | ||
|
||
curl -XPUT http://broker/pacticipants/Bar/branches/main/versions/1e70030c6579915e5ff56b107a0fd25cf5df7464 \ | ||
-H "Content-Type: application/json" -d "{}" | ||
|
||
|
||
## Delete | ||
|
||
Removes a pacticipant version from a branch. Does not delete the actual pacticipant version. | ||
|
||
Send a `DELETE` request to the branch version resource. | ||
|
||
curl -XDELETE http://broker/pacticipants/Bar/branches/main/versions/1e70030c6579915e5ff56b107a0fd25cf5df7464 |
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,30 @@ | ||
describe "Deleting a branch version (removing a version from a branch)" do | ||
before do | ||
td.create_consumer("foo") | ||
.create_consumer_version("1234", branch: "main") | ||
.create_consumer_version("1234", branch: "not-main") | ||
.create_consumer_version("555", branch: "main") | ||
.create_consumer("bar") | ||
.create_consumer_version("1234", branch: "main") | ||
end | ||
|
||
let(:path) { "/pacticipants/foo/branches/main/versions/1234" } | ||
let(:headers) { { "CONTENT_TYPE" => "application/json" } } | ||
let(:response_body) { JSON.parse(subject.body, symbolize_names: true) } | ||
|
||
subject { delete(path, {}, headers) } | ||
|
||
it "returns a 204 response" do | ||
expect(subject.status).to be 204 | ||
end | ||
|
||
it "deletes the branch version" do | ||
expect { subject }.to change { PactBroker::Versions::BranchVersion.count }.by(-1) | ||
end | ||
|
||
context "when the branch version does not exist" do | ||
let(:path) { "/pacticipants/foo/branches/main/versions/888" } | ||
|
||
its(:status) { is_expected.to eq 404 } | ||
end | ||
end |