pact_broker-client 1.39.0 → 1.44.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +21 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +52 -0
- data/Gemfile +4 -0
- data/README.md +39 -18
- data/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +79 -280
- data/lib/pact_broker/client/backports.rb +9 -0
- data/lib/pact_broker/client/base_command.rb +95 -0
- data/lib/pact_broker/client/can_i_deploy.rb +20 -3
- data/lib/pact_broker/client/cli/broker.rb +20 -75
- data/lib/pact_broker/client/cli/custom_thor.rb +12 -0
- data/lib/pact_broker/client/cli/deployment_commands.rb +74 -0
- data/lib/pact_broker/client/cli/environment_commands.rb +70 -0
- data/lib/pact_broker/client/cli/pacticipant_commands.rb +53 -0
- data/lib/pact_broker/client/cli/record_deployment_long_desc.txt +0 -55
- data/lib/pact_broker/client/cli/version_selector_options_parser.rb +4 -0
- data/lib/pact_broker/client/colorize_notices.rb +31 -0
- data/lib/pact_broker/client/deployments.rb +4 -0
- data/lib/pact_broker/client/deployments/record_deployment.rb +38 -0
- data/lib/pact_broker/client/deployments/record_release.rb +99 -0
- data/lib/pact_broker/client/deployments/record_undeployment.rb +120 -0
- data/lib/pact_broker/client/describe_text_formatter.rb +23 -0
- data/lib/pact_broker/client/environments.rb +6 -0
- data/lib/pact_broker/client/environments/create_environment.rb +31 -0
- data/lib/pact_broker/client/environments/delete_environment.rb +27 -0
- data/lib/pact_broker/client/environments/describe_environment.rb +26 -0
- data/lib/pact_broker/client/environments/environment_command.rb +66 -0
- data/lib/pact_broker/client/environments/list_environments.rb +30 -0
- data/lib/pact_broker/client/environments/text_formatter.rb +30 -0
- data/lib/pact_broker/client/environments/update_environment.rb +31 -0
- data/lib/pact_broker/client/generate_display_name.rb +27 -0
- data/lib/pact_broker/client/hal/entity.rb +14 -4
- data/lib/pact_broker/client/hal/http_client.rb +8 -2
- data/lib/pact_broker/client/hal/link.rb +8 -0
- data/lib/pact_broker/client/hal_client_methods.rb +1 -3
- data/lib/pact_broker/client/matrix.rb +4 -0
- data/lib/pact_broker/client/matrix/abbreviate_version_number.rb +15 -0
- data/lib/pact_broker/client/matrix/resource.rb +26 -1
- data/lib/pact_broker/client/matrix/text_formatter.rb +28 -17
- data/lib/pact_broker/client/pacticipants.rb +6 -0
- data/lib/pact_broker/client/pacticipants/create.rb +24 -34
- data/lib/pact_broker/client/pacticipants/describe.rb +33 -0
- data/lib/pact_broker/client/pacticipants/list.rb +34 -0
- data/lib/pact_broker/client/pacticipants/text_formatter.rb +41 -0
- data/lib/pact_broker/client/publish_pacts.rb +7 -3
- data/lib/pact_broker/client/string_refinements.rb +56 -0
- data/lib/pact_broker/client/version.rb +1 -1
- data/lib/pact_broker/client/versions.rb +4 -1
- data/lib/pact_broker/client/versions/describe.rb +3 -1
- data/lib/pact_broker/client/versions/formatter.rb +3 -1
- data/lib/pact_broker/client/versions/json_formatter.rb +5 -3
- data/lib/pact_broker/client/versions/text_formatter.rb +3 -1
- data/pact-broker-client.gemspec +2 -0
- data/script/approve-all.sh +6 -0
- data/script/publish-pact.sh +24 -6
- data/script/record-deployments-and-releases.sh +10 -0
- data/spec/fixtures/approvals/can_i_deploy_ignore.approved.txt +13 -0
- data/spec/fixtures/approvals/describe_environment.approved.txt +7 -0
- data/spec/fixtures/approvals/describe_pacticipant.approved.txt +2 -0
- data/spec/fixtures/approvals/list_environments.approved.txt +3 -0
- data/spec/integration/describe_environment_spec.rb +31 -0
- data/spec/lib/pact_broker/client/can_i_deploy_spec.rb +47 -5
- data/spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb +5 -5
- data/spec/lib/pact_broker/client/cli/broker_publish_spec.rb +1 -1
- data/spec/lib/pact_broker/client/cli/broker_run_webhook_commands_spec.rb +3 -3
- data/spec/lib/pact_broker/client/cli/version_selector_options_parser_spec.rb +21 -0
- data/spec/lib/pact_broker/client/deployments/record_deployment_spec.rb +204 -0
- data/spec/lib/pact_broker/client/environments/delete_environment_spec.rb +120 -0
- data/spec/lib/pact_broker/client/environments/describe_environment_spec.rb +89 -0
- data/spec/lib/pact_broker/client/environments/update_environment_spec.rb +167 -0
- data/spec/lib/pact_broker/client/generate_display_name_spec.rb +39 -0
- data/spec/lib/pact_broker/client/hal/entity_spec.rb +2 -2
- data/spec/lib/pact_broker/client/pacticipants/create_spec.rb +2 -2
- data/spec/pacts/pact_broker_client-pact_broker.json +88 -287
- data/spec/service_providers/create_environment_spec.rb +78 -0
- data/spec/service_providers/list_environments_spec.rb +77 -0
- data/spec/service_providers/pact_broker_client_matrix_ignore_spec.rb +98 -0
- data/spec/service_providers/pacticipants_create_spec.rb +5 -4
- data/spec/service_providers/publish_pacts_spec.rb +5 -2
- data/spec/service_providers/record_deployment_spec.rb +17 -36
- data/spec/service_providers/record_release_spec.rb +135 -0
- data/spec/spec_helper.rb +15 -2
- data/spec/support/approvals.rb +26 -0
- data/spec/support/shared_context.rb +6 -2
- data/tasks/pact.rake +19 -1
- metadata +93 -7
- data/lib/pact_broker/client/versions/record_deployment.rb +0 -109
- data/lib/pact_broker/client/versions/record_undeployment.rb +0 -102
- data/spec/lib/pact_broker/client/versions/record_deployment_spec.rb +0 -82
@@ -292,6 +292,94 @@
|
|
292
292
|
}
|
293
293
|
}
|
294
294
|
},
|
295
|
+
{
|
296
|
+
"description": "a request to determine if Bar can be deployed with all Foo tagged prod, ignoring the verification for Foo version 3.4.5",
|
297
|
+
"providerState": "provider Bar version 4.5.6 has a successful verification for Foo version 1.2.3 tagged prod and a failed verification for version 3.4.5 tagged prod",
|
298
|
+
"request": {
|
299
|
+
"method": "get",
|
300
|
+
"path": "/matrix",
|
301
|
+
"query": "q%5B%5D%5Bpacticipant%5D=Bar&q%5B%5D%5Bversion%5D=4.5.6&q%5B%5D%5Bpacticipant%5D=Foo&q%5B%5D%5Btag%5D=prod&latestby=cvpv&ignore%5B%5D%5Bpacticipant%5D=Foo&ignore%5B%5D%5Bversion%5D=3.4.5"
|
302
|
+
},
|
303
|
+
"response": {
|
304
|
+
"status": 200,
|
305
|
+
"headers": {
|
306
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
307
|
+
},
|
308
|
+
"body": {
|
309
|
+
"summary": {
|
310
|
+
"deployable": true,
|
311
|
+
"ignored": 1
|
312
|
+
},
|
313
|
+
"notices": [
|
314
|
+
{
|
315
|
+
"text": "some notice",
|
316
|
+
"type": "info"
|
317
|
+
}
|
318
|
+
],
|
319
|
+
"matrix": [
|
320
|
+
{
|
321
|
+
"consumer": {
|
322
|
+
"name": "Foo",
|
323
|
+
"version": {
|
324
|
+
"number": "1.2.3"
|
325
|
+
}
|
326
|
+
},
|
327
|
+
"provider": {
|
328
|
+
"name": "Bar",
|
329
|
+
"version": {
|
330
|
+
"number": "4.5.6"
|
331
|
+
}
|
332
|
+
},
|
333
|
+
"verificationResult": {
|
334
|
+
"success": true,
|
335
|
+
"_links": {
|
336
|
+
"self": {
|
337
|
+
"href": "http://result"
|
338
|
+
}
|
339
|
+
}
|
340
|
+
}
|
341
|
+
},
|
342
|
+
{
|
343
|
+
"consumer": {
|
344
|
+
"name": "Foo",
|
345
|
+
"version": {
|
346
|
+
"number": "3.4.5"
|
347
|
+
}
|
348
|
+
},
|
349
|
+
"provider": {
|
350
|
+
"name": "Bar",
|
351
|
+
"version": {
|
352
|
+
"number": "4.5.6"
|
353
|
+
}
|
354
|
+
},
|
355
|
+
"verificationResult": {
|
356
|
+
"success": false,
|
357
|
+
"_links": {
|
358
|
+
"self": {
|
359
|
+
"href": "http://result"
|
360
|
+
}
|
361
|
+
}
|
362
|
+
},
|
363
|
+
"ignored": true
|
364
|
+
}
|
365
|
+
]
|
366
|
+
},
|
367
|
+
"matchingRules": {
|
368
|
+
"$.body.notices": {
|
369
|
+
"min": 1
|
370
|
+
},
|
371
|
+
"$.body.notices[*].*": {
|
372
|
+
"match": "type"
|
373
|
+
},
|
374
|
+
"$.body.matrix[0].verificationResult._links.self.href": {
|
375
|
+
"match": "type"
|
376
|
+
},
|
377
|
+
"$.body.matrix[1].verificationResult._links.self.href": {
|
378
|
+
"match": "type"
|
379
|
+
}
|
380
|
+
}
|
381
|
+
}
|
382
|
+
},
|
295
383
|
{
|
296
384
|
"description": "a request for the compatibility matrix for Foo version 1.2.3 and Bar version 4.5.6",
|
297
385
|
"providerState": "the pact for Foo version 1.2.3 has been verified by Bar version 4.5.6",
|
@@ -1550,293 +1638,6 @@
|
|
1550
1638
|
}
|
1551
1639
|
}
|
1552
1640
|
},
|
1553
|
-
{
|
1554
|
-
"description": "a request for the index resource",
|
1555
|
-
"providerState": "the pb:publish-contracts relations exists in the index resource",
|
1556
|
-
"request": {
|
1557
|
-
"method": "GET",
|
1558
|
-
"path": "/",
|
1559
|
-
"headers": {
|
1560
|
-
"Accept": "application/hal+json"
|
1561
|
-
}
|
1562
|
-
},
|
1563
|
-
"response": {
|
1564
|
-
"status": 200,
|
1565
|
-
"headers": {
|
1566
|
-
"Content-Type": "application/hal+json;charset=utf-8"
|
1567
|
-
},
|
1568
|
-
"body": {
|
1569
|
-
"_links": {
|
1570
|
-
"pb:publish-contracts": {
|
1571
|
-
"href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-PUBLISH-CONTRACTS"
|
1572
|
-
}
|
1573
|
-
}
|
1574
|
-
},
|
1575
|
-
"matchingRules": {
|
1576
|
-
"$.body._links.pb:publish-contracts.href": {
|
1577
|
-
"match": "regex",
|
1578
|
-
"regex": "http:\\/\\/.*"
|
1579
|
-
}
|
1580
|
-
}
|
1581
|
-
}
|
1582
|
-
},
|
1583
|
-
{
|
1584
|
-
"description": "a request to publish contracts",
|
1585
|
-
"request": {
|
1586
|
-
"method": "POST",
|
1587
|
-
"path": "/HAL-REL-PLACEHOLDER-PB-PUBLISH-CONTRACTS",
|
1588
|
-
"headers": {
|
1589
|
-
"Content-Type": "application/json",
|
1590
|
-
"Accept": "application/hal+json"
|
1591
|
-
},
|
1592
|
-
"body": {
|
1593
|
-
"pacticipantName": "Foo",
|
1594
|
-
"pacticipantVersionNumber": "5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
|
1595
|
-
"branch": "main",
|
1596
|
-
"tags": [
|
1597
|
-
"dev"
|
1598
|
-
],
|
1599
|
-
"buildUrl": "http://build",
|
1600
|
-
"contracts": [
|
1601
|
-
{
|
1602
|
-
"consumerName": "Foo",
|
1603
|
-
"providerName": "Bar",
|
1604
|
-
"specification": "pact",
|
1605
|
-
"contentType": "application/json",
|
1606
|
-
"content": "eyJjb25zdW1lciI6eyJuYW1lIjoiRm9vIn0sInByb3ZpZGVyIjp7Im5hbWUiOiJCYXIifSwiaW50ZXJhY3Rpb25zIjpbeyJkZXNjcmlwdGlvbiI6ImFuIGV4YW1wbGUgcmVxdWVzdCIsInByb3ZpZGVyU3RhdGUiOiJhIHByb3ZpZGVyIHN0YXRlIiwicmVxdWVzdCI6eyJtZXRob2QiOiJHRVQiLCJwYXRoIjoiLyIsImhlYWRlcnMiOnt9fSwicmVzcG9uc2UiOnsic3RhdHVzIjoyMDAsImhlYWRlcnMiOnsiQ29udGVudC1UeXBlIjoiYXBwbGljYXRpb24vaGFsK2pzb24ifX19XSwibWV0YWRhdGEiOnsicGFjdFNwZWNpZmljYXRpb24iOnsidmVyc2lvbiI6IjIuMC4wIn19fQ==",
|
1607
|
-
"writeMode": "overwrite"
|
1608
|
-
}
|
1609
|
-
]
|
1610
|
-
}
|
1611
|
-
},
|
1612
|
-
"response": {
|
1613
|
-
"status": 200,
|
1614
|
-
"headers": {
|
1615
|
-
"Content-Type": "application/hal+json;charset=utf-8"
|
1616
|
-
},
|
1617
|
-
"body": {
|
1618
|
-
"_embedded": {
|
1619
|
-
"pacticipant": {
|
1620
|
-
"name": "Foo"
|
1621
|
-
},
|
1622
|
-
"version": {
|
1623
|
-
"number": "5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
|
1624
|
-
"buildUrl": "http://build"
|
1625
|
-
}
|
1626
|
-
},
|
1627
|
-
"logs": [
|
1628
|
-
{
|
1629
|
-
"level": "info",
|
1630
|
-
"message": "some message"
|
1631
|
-
}
|
1632
|
-
],
|
1633
|
-
"_links": {
|
1634
|
-
"pb:pacticipant-version-tags": [
|
1635
|
-
{
|
1636
|
-
"name": "dev"
|
1637
|
-
}
|
1638
|
-
],
|
1639
|
-
"pb:contracts": [
|
1640
|
-
{
|
1641
|
-
"href": "http://some-pact"
|
1642
|
-
}
|
1643
|
-
]
|
1644
|
-
}
|
1645
|
-
},
|
1646
|
-
"matchingRules": {
|
1647
|
-
"$.body.logs": {
|
1648
|
-
"min": 1
|
1649
|
-
},
|
1650
|
-
"$.body.logs[*].*": {
|
1651
|
-
"match": "type"
|
1652
|
-
},
|
1653
|
-
"$.body._links.pb:contracts[0].href": {
|
1654
|
-
"match": "type"
|
1655
|
-
}
|
1656
|
-
}
|
1657
|
-
}
|
1658
|
-
},
|
1659
|
-
{
|
1660
|
-
"description": "a request for the index resource",
|
1661
|
-
"providerState": "the pb:pacticipant-version and pb:environments relations exist in the index resource",
|
1662
|
-
"request": {
|
1663
|
-
"method": "GET",
|
1664
|
-
"path": "/",
|
1665
|
-
"headers": {
|
1666
|
-
"Accept": "application/hal+json"
|
1667
|
-
}
|
1668
|
-
},
|
1669
|
-
"response": {
|
1670
|
-
"status": 200,
|
1671
|
-
"headers": {
|
1672
|
-
"Content-Type": "application/hal+json;charset=utf-8"
|
1673
|
-
},
|
1674
|
-
"body": {
|
1675
|
-
"_links": {
|
1676
|
-
"pb:pacticipant-version": {
|
1677
|
-
"href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-{pacticipant}-{version}"
|
1678
|
-
},
|
1679
|
-
"pb:environments": {
|
1680
|
-
"href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS"
|
1681
|
-
}
|
1682
|
-
}
|
1683
|
-
},
|
1684
|
-
"matchingRules": {
|
1685
|
-
"$.body._links.pb:pacticipant-version.href": {
|
1686
|
-
"match": "regex",
|
1687
|
-
"regex": "http:\\/\\/.*{pacticipant}.*{version}"
|
1688
|
-
},
|
1689
|
-
"$.body._links.pb:environments.href": {
|
1690
|
-
"match": "regex",
|
1691
|
-
"regex": "http:\\/\\/.*"
|
1692
|
-
}
|
1693
|
-
}
|
1694
|
-
}
|
1695
|
-
},
|
1696
|
-
{
|
1697
|
-
"description": "a request for a pacticipant version",
|
1698
|
-
"providerState": "version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for deployment",
|
1699
|
-
"request": {
|
1700
|
-
"method": "GET",
|
1701
|
-
"path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
|
1702
|
-
"headers": {
|
1703
|
-
"Accept": "application/hal+json"
|
1704
|
-
}
|
1705
|
-
},
|
1706
|
-
"response": {
|
1707
|
-
"status": 200,
|
1708
|
-
"headers": {
|
1709
|
-
"Content-Type": "application/hal+json;charset=utf-8"
|
1710
|
-
},
|
1711
|
-
"body": {
|
1712
|
-
"_links": {
|
1713
|
-
"pb:record-deployment": [
|
1714
|
-
{
|
1715
|
-
"name": "test",
|
1716
|
-
"href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-RECORD-DEPLOYMENT-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST"
|
1717
|
-
}
|
1718
|
-
]
|
1719
|
-
}
|
1720
|
-
},
|
1721
|
-
"matchingRules": {
|
1722
|
-
"$.body._links.pb:record-deployment[0].href": {
|
1723
|
-
"match": "regex",
|
1724
|
-
"regex": "http:\\/\\/.*"
|
1725
|
-
}
|
1726
|
-
}
|
1727
|
-
}
|
1728
|
-
},
|
1729
|
-
{
|
1730
|
-
"description": "a request to record a deployment",
|
1731
|
-
"providerState": "version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for deployment",
|
1732
|
-
"request": {
|
1733
|
-
"method": "POST",
|
1734
|
-
"path": "/HAL-REL-PLACEHOLDER-PB-RECORD-DEPLOYMENT-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST",
|
1735
|
-
"headers": {
|
1736
|
-
"Content-Type": "application/json",
|
1737
|
-
"Accept": "application/hal+json"
|
1738
|
-
},
|
1739
|
-
"body": {
|
1740
|
-
"replacedPreviousDeployedVersion": true
|
1741
|
-
}
|
1742
|
-
},
|
1743
|
-
"response": {
|
1744
|
-
"status": 201,
|
1745
|
-
"headers": {
|
1746
|
-
"Content-Type": "application/hal+json;charset=utf-8"
|
1747
|
-
},
|
1748
|
-
"body": {
|
1749
|
-
"replacedPreviousDeployedVersion": true
|
1750
|
-
}
|
1751
|
-
}
|
1752
|
-
},
|
1753
|
-
{
|
1754
|
-
"description": "a request for a pacticipant version",
|
1755
|
-
"providerState": "version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo does not exist",
|
1756
|
-
"request": {
|
1757
|
-
"method": "GET",
|
1758
|
-
"path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
|
1759
|
-
"headers": {
|
1760
|
-
"Accept": "application/hal+json"
|
1761
|
-
}
|
1762
|
-
},
|
1763
|
-
"response": {
|
1764
|
-
"status": 404,
|
1765
|
-
"headers": {
|
1766
|
-
}
|
1767
|
-
}
|
1768
|
-
},
|
1769
|
-
{
|
1770
|
-
"description": "a request for a pacticipant version",
|
1771
|
-
"providerState": "version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with 2 environments that aren't test available for deployment",
|
1772
|
-
"request": {
|
1773
|
-
"method": "GET",
|
1774
|
-
"path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
|
1775
|
-
"headers": {
|
1776
|
-
"Accept": "application/hal+json"
|
1777
|
-
}
|
1778
|
-
},
|
1779
|
-
"response": {
|
1780
|
-
"status": 200,
|
1781
|
-
"headers": {
|
1782
|
-
"Content-Type": "application/hal+json;charset=utf-8"
|
1783
|
-
},
|
1784
|
-
"body": {
|
1785
|
-
"_links": {
|
1786
|
-
"pb:record-deployment": [
|
1787
|
-
{
|
1788
|
-
"name": "prod",
|
1789
|
-
"href": "href"
|
1790
|
-
},
|
1791
|
-
{
|
1792
|
-
"name": "dev",
|
1793
|
-
"href": "href"
|
1794
|
-
}
|
1795
|
-
]
|
1796
|
-
}
|
1797
|
-
},
|
1798
|
-
"matchingRules": {
|
1799
|
-
"$.body._links.pb:record-deployment[0]": {
|
1800
|
-
"match": "type"
|
1801
|
-
},
|
1802
|
-
"$.body._links.pb:record-deployment[1]": {
|
1803
|
-
"match": "type"
|
1804
|
-
}
|
1805
|
-
}
|
1806
|
-
}
|
1807
|
-
},
|
1808
|
-
{
|
1809
|
-
"description": "a request for the environments",
|
1810
|
-
"providerState": "an environment with name test exists",
|
1811
|
-
"request": {
|
1812
|
-
"method": "GET",
|
1813
|
-
"path": "/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS",
|
1814
|
-
"headers": {
|
1815
|
-
"Accept": "application/hal+json"
|
1816
|
-
}
|
1817
|
-
},
|
1818
|
-
"response": {
|
1819
|
-
"status": 200,
|
1820
|
-
"headers": {
|
1821
|
-
"Content-Type": "application/hal+json;charset=utf-8"
|
1822
|
-
},
|
1823
|
-
"body": {
|
1824
|
-
"_links": {
|
1825
|
-
"pb:environments": [
|
1826
|
-
{
|
1827
|
-
"name": "test",
|
1828
|
-
"href": "href"
|
1829
|
-
}
|
1830
|
-
]
|
1831
|
-
}
|
1832
|
-
},
|
1833
|
-
"matchingRules": {
|
1834
|
-
"$.body._links.pb:environments[0].href": {
|
1835
|
-
"match": "type"
|
1836
|
-
}
|
1837
|
-
}
|
1838
|
-
}
|
1839
|
-
},
|
1840
1641
|
{
|
1841
1642
|
"description": "a request to create a webhook with a JSON body for a consumer and provider",
|
1842
1643
|
"providerState": "the 'Pricing Service' and 'Condor' already exist in the pact-broker",
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'service_providers/pact_helper'
|
2
|
+
require 'pact_broker/client/environments/create_environment'
|
3
|
+
|
4
|
+
RSpec.describe "create an environment", pact: true, skip: true do
|
5
|
+
include_context "pact broker"
|
6
|
+
include PactBrokerPactHelperMethods
|
7
|
+
|
8
|
+
let(:params) do
|
9
|
+
{
|
10
|
+
name: "test",
|
11
|
+
display_name: "Test",
|
12
|
+
production: false,
|
13
|
+
contact_name: "Foo team",
|
14
|
+
contact_email_address: "foo@bar.com"
|
15
|
+
|
16
|
+
}
|
17
|
+
end
|
18
|
+
let(:pact_broker_client_options) { {} }
|
19
|
+
let(:request_body) do
|
20
|
+
{
|
21
|
+
name: "test",
|
22
|
+
displayName: "Test",
|
23
|
+
production: false,
|
24
|
+
contacts: [{
|
25
|
+
name: "Foo team",
|
26
|
+
details: {
|
27
|
+
emailAddress: "foo@bar.com"
|
28
|
+
}
|
29
|
+
}]
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
subject { PactBroker::Client::Environments::CreateEnvironment.call(params, broker_base_url, pact_broker_client_options) }
|
34
|
+
|
35
|
+
def mock_index
|
36
|
+
pact_broker
|
37
|
+
.given("the pb:environments relation exists in the index resource")
|
38
|
+
.upon_receiving("a request for the index resource")
|
39
|
+
.with(
|
40
|
+
method: "GET",
|
41
|
+
path: '/',
|
42
|
+
headers: get_request_headers).
|
43
|
+
will_respond_with(
|
44
|
+
status: 200,
|
45
|
+
headers: pact_broker_response_headers,
|
46
|
+
body: {
|
47
|
+
_links: {
|
48
|
+
:'pb:environments' => {
|
49
|
+
href: placeholder_url_term("pb:environments")
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
def mock_environment_creation_request
|
57
|
+
pact_broker
|
58
|
+
.upon_receiving("a request to create an environment")
|
59
|
+
.with(
|
60
|
+
method: "POST",
|
61
|
+
path: "/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS",
|
62
|
+
headers: post_request_headers,
|
63
|
+
body: request_body
|
64
|
+
)
|
65
|
+
.will_respond_with(
|
66
|
+
status: 201,
|
67
|
+
headers: pact_broker_response_headers,
|
68
|
+
body: request_body.merge("uuid" => Pact.like("ffe683ef-dcd7-4e4f-877d-f6eb3db8e86e"))
|
69
|
+
)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "returns a success result" do
|
73
|
+
mock_index
|
74
|
+
mock_environment_creation_request
|
75
|
+
expect(subject.success).to be true
|
76
|
+
expect(subject.message).to include "Created test environment in the Pact Broker with UUID ffe683ef-dcd7-4e4f-877d-f6eb3db8e86e"
|
77
|
+
end
|
78
|
+
end
|