PageSourceSearch

https://docs-pactflow-preview.netlify.app/assets/js/0f90e217.66ccbb32.js

js docs-pactflow-preview.netlify.app collected 2026-10-03 10:40:33 UTC 11,157 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkpartners=self.webpackChunkpartners||[]).push([[8243],{15680:(e,t,n)=>{n.d(t,{xA:()=>c,yg:()=>m});var r=n(96540);function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function s(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var l=r.createContext({}),p=function(e){var t=r.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):a(a({},t),e)),n},c=function(e){var t=p(e.components);return r.createElement(l.Provider,{value:t},e.children)},d="mdxType",u={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},h=r.forwardRef((function(e,t){var n=e.components,i=e.mdxType,o=e.originalType,l=e.parentName,c=s(e,["components","mdxType","originalType","parentName"]),d=p(n),h=i,m=d["".concat(l,".").concat(h)]||d[h]||u[h]||o;return n?r.createElement(m,a(a({ref:t},c),{},{components:n})):r.createElement(m,a({ref:t},c))}));function m(e,t){var n=arguments,i=t&&t.mdxType;if("string"==typeof e||i){var o=n.length,a=new Array(o);a[0]=h;var s={};for(var l in t)hasOwnProperty.call(t,l)&&(s[l]=t[l]);s.originalType=e,s[d]="string"==typeof e?e:i,a[1]=s;for(var p=2;p<o;p++)a[p]=n[p];return r.createElement.apply(null,a)}return r.createElement.apply(null,n)}h.displayName="MDXCreateElement"},65719:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>l,contentTitle:()=>a,default:()=>u,frontMatter:()=>o,metadata:()=>s,toc:()=>p});var r=n(58168),i=(n(96540),n(15680));const o={id:"implementing-the-provider-changes",title:"Implementing the provider changes"},a=void 0,s={unversionedId:"docs/workshops/ci-cd/workshop/implementing-the-provider-changes",id:"docs/workshops/ci-cd/workshop/implementing-the-provider-changes",title:"Implementing the provider changes",description:"The next step is to implement the changes that have been requested in the pact.",source:"@site/docs/docs/workshops/ci-cd/workshop/05_implementing_the_provider_changes.md",sourceDirName:"docs/workshops/ci-cd/workshop",slug:"/docs/workshops/ci-cd/workshop/implementing-the-provider-changes",permalink:"/docs/workshops/ci-cd/workshop/implementing-the-provider-changes",draft:!1,editUrl:"https://github.com/pactflow/docs.pactflow.io/edit/master/website/docs/docs/workshops/ci-cd/workshop/05_implementing_the_provider_changes.md",tags:[],version:"current",lastUpdatedBy:"Lucas",lastUpdatedAt:1682093400,formattedLastUpdatedAt:"Apr 21, 2023",sidebarPosition:5,frontMatter:{id:"implementing-the-provider-changes",title:"Implementing the provider changes"},sidebar:"university",previous:{title:"How not to break everything",permalink:"/docs/workshops/ci-cd/workshop/how-not-to-break-everything"},next:{title:"Strategies for verifying feature pacts",permalink:"/docs/workshops/ci-cd/workshop/verifying-feature-pacts"}},l={},p=[{value:"Expected state by the end of this step",id:"expected-state-by-the-end-of-this-step",level:2},{value:"Conclusion",id:"conclusion",level:2}],c={toc:p},d="wrapper";
1function u(e){let{components:t,...n}=e;return(0,i.yg)(d,(0,r.A)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,i.yg)("p",null,"The next step is to implement the changes that have been requested in the pact."),(0,i.yg)("ol",null,(0,i.yg)("li",{parentName:"ol"},(0,i.yg)("p",{parentName:"li"},"Open up the terminal for your provider project.")),(0,i.yg)("li",{parentName:"ol"},(0,i.yg)("p",{parentName:"li"},"Run ",(0,i.yg)("inlineCode",{parentName:"p"},"make test")," to make sure everything is passing before you start."),(0,i.yg)("ol",{parentName:"li"},(0,i.yg)("li",{parentName:"ol"},"Your test run should exit successfully, but show the failing verification from our consumers feature branch. If we didn't have ",(0,i.yg)("inlineCode",{parentName:"li"},"enablePending")," set, this would exit with a failure.")),(0,i.yg)("ul",{parentName:"li"},(0,i.yg)("li",{parentName:"ul"},'\ud83d\udc49 This will run our unit tests and our Pact test which "fetch pacts for these consumer version selectors" mode. This is executed as part of the following GitHub workflow ',(0,i.yg)("inlineCode",{parentName:"li"}
1,".github/workflows/build.yml")))),(0,i.yg)("li",{parentName:"ol"},(0,i.yg)("p",{parentName:"li"},"Get the URL of the new pact:"),(0,i.yg)("ul",{parentName:"li"},(0,i.yg)("li",{parentName:"ul"},"Go to your PactFlow account, find the new pact on the consumer branch ",(0,i.yg)("inlineCode",{parentName:"li"},"feat/new-field"),' and click "VIEW PACT".'),(0,i.yg)("li",{parentName:"ul"},"In the top right, click the 3 dots and select ",(0,i.yg)("inlineCode",{parentName:"li"},"Copy pact URL for pactflow-example-consumer version xyz"),"."))),(0,i.yg)("li",{parentName:"ol"},(0,i.yg)("p",{parentName:"li"},"Run ",(0,i.yg)("inlineCode",{parentName:"p"},"PACT_URL=<PACT URL HERE> make ci_webhook"),". This test should correctly fail with the error ",(0,i.yg)("inlineCode",{parentName:"p"},'Could not find key "color"')," in the output."),(0,i.yg)("ul",{parentName:"li"},(0,i.yg)("li",{parentName:"ul"},"\ud83d\udc49 We run a new command here ",(0,i.yg)("inlineCode",{parentName:"li"},"make ci_webhook"),'. This allows us to "verify a custom pact", it works because of the code in ',(0,i.yg)("inlineCode",{parentName:"li"},"src/product/product.consumerChange.pact.test.js")),(0,i.yg)("li",{parentName:"ul"},"Rather than our ",(0,i.yg)("inlineCode",{parentName:"li"},"product.providerChange.pact.test.js"),' test which "fetch pacts for these consumer version selectors" mode, by running ',(0,i.yg)("inlineCode",{parentName:"li"},"make test")," who workflow in GitHub is in this file ",(0,i.yg)("inlineCode",{parentName:"li"},".github/workflows/build.yml")),(0,i.yg)("li",{parentName:"ul"},"When running ",(0,i.yg)("inlineCode",{parentName:"li"},"make ci_webhook"),", The ",(0,i.yg)("inlineCode",{parentName:"li"},"$PACT_URL"),' is passed in when the build is triggered by a "contract requiring verification published" webhook, and allows us to verify just the changed pact against the providers main branch and any deployed (or released) versions. The workflow in GitHub is in this file ',(0,i.yg)("inlineCode",{parentName:"li"},".github/workflows/contract_requiring_verification_published.yml")),(0,i.yg)("li",{parentName:"ul"},"We share the base Pact setup in ",(0,i.yg)("inlineCode",{parentName:"li"},"src/product/pact.setup.js")," for both types of Pact verification, so both can re-use ",(0,i.yg)("inlineCode",{parentName:"li"},"Provider States")," / ",(0,i.yg)("inlineCode",{parentName:"li"},"Request filters")," and core setup common to both tasks."))),(0,i.yg)("li",{parentName:"ol"},(0,i.yg)("p",{parentName:"li"},"Make the test pass by adding a ",(0,i.yg)("inlineCode",{parentName:"p"},"color")," field to ",(0,i.yg)("inlineCode",{parentName:"p"},"product/product.js"),", and adding the new color argument to the Product initialization lines in ",(0,i.yg)("inlineCode",{parentName:"p"},"product/product.repository.js")," and the provider states in ",(0,i.yg)("inlineCode",{parentName:"p"},"product/pact.setup.js"),"."),(0,i.yg)("pre",{parentName:"li"},(0,i.yg)("code",{parentName:"pre",className:"language-js"},"constructor(id, type, name, version, color) {\n  this.id = id;\n  this.type = type;\n  this.name = name;\n  this.version = version;\n  this.color = color;\n}\n")),(0,i.yg)("pre",{parentName:"li"},(0,i.yg)("code",{parentName:"pre",className:"language-js"},'constructor() {\n    this.products = new Map([\n        ["09", new Product("09", "CREDIT_CARD", "Gem Visa", "v1", "green")],\n        ["10", new Product("10", "CREDIT_CARD", "28 Degrees", "v1", "blue")],\n        ["11", new Product("11", "PERSONAL_LOAN", "MyFlexiPay", "v2", "yellow")],\n    ]);\n}\n')),(0,i.yg)("pre",{parentName:"li"},(0,i.yg)("code",{parentName:"pre",className:"language-js"},'const stateHandlers = {\n  "products exists": () => {\n    controller.repository.products = new Map([\n      ["10", new Product("10", "CREDIT_CARD", "28 Degrees", "v1","blue")],\n    ]);\n  },\n  "products exist": () => {\n    controller.repository.products = new Map([\n      ["10", new Product("10", "CREDIT_CARD", "28 Degrees", "v1","blue")],\n    ]);\n  },\n  "a product with ID 10 exists": () => {\n    controller.repository.products = new Map([\n      ["10", new Product("10", "CREDIT_CARD", "28 Degrees", "v1","blue")],\n    ]);\n  },\n  "a product with ID 11 does not exist": () => {\n    controller.repository.products = new Map();\n  },\n};\n'))),(0,i.yg)("li",{parentName:"ol"},(0,i.yg)("p",{parentName:"li"},"Run ",(0,i.yg)("inlineCode",{parentName:"p"},"PACT_URL=<PACT URL HERE> make ci_webhook")," and you should have a passing test suite. \u2705")),(0,i.yg)("li",{parentName:"ol"},(0,i.yg)("p",{parentName:"li"}
1,"We won't commit our changes until the next step."))),(0,i.yg)("h2",{id:"expected-state-by-the-end-of-this-step"},"Expected state by the end of this step"),(0,i.yg)("ul",null,(0,i.yg)("li",{parentName:"ul"},"A passing provider build in Github Actions."),(0,i.yg)("li",{parentName:"ul"},"Local changes on your provider codebase that implements the features required by the ",(0,i.yg)("inlineCode",{parentName:"li"},"feat/new-field")," pact on its ",(0,i.yg)("inlineCode",{parentName:"li"},"master")," branch."),(0,i.yg)("li",{parentName:"ul"},"A ",(0,i.yg)("inlineCode",{parentName:"li"},"feat/new-field")," pact with a failed verification result")),(0,i.yg)("h2",{id:"conclusion"},"Conclusion"),(0,i.yg)("p",null,"The ",(0,i.yg)("inlineCode",{parentName:"p"},"master")," provider is now compatible with the ",(0,i.yg)("inlineCode",{parentName:"p"},"feat/new-field")," pact, based on your local changes. However, there is still a failing verification result published for the ",(0,i.yg)("inlineCode",{parentName:"p"},"feat/new-field")," pact, triggered by a webhook (contract requiring verification published) when the new pact was published."),(0,i.yg)("p",null,"We verified the Pact would pass against our providers main branch ",(0,i.yg)("inlineCode",{parentName:"p"},"master")," by passing in the Pact URL directly, however because it was only verified on a development machine, and we don't typically publish verification results from dev machines."),(0,i.yg)("p",null,"The next step is getting a result back to PactFlow so that the consumer knows they are safe to merge."))}u.isMDXComponent=!0}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.