PageSourceSearch

https://docs-pactflow-preview.netlify.app/assets/js/fc5743bb.93e7f937.js

js docs-pactflow-preview.netlify.app collected 2026-10-03 10:42:11 UTC 9,989 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkpartners=self.webpackChunkpartners||[]).push([[26089],{15680:(e,t,n)=>{n.d(t,{xA:()=>c,yg:()=>h});var r=n(96540);function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(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 o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function p(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var s=r.createContext({}),l=function(e){var t=r.useContext(s),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},c=function(e){var t=l(e.components);return r.createElement(s.Provider,{value:t},e.children)},d="mdxType",u={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},g=r.forwardRef((function(e,t){var n=e.components,a=e.mdxType,i=e.originalType,s=e.parentName,c=p(e,["components","mdxType","originalType","parentName"]),d=l(n),g=a,h=d["".concat(s,".").concat(g)]||d[g]||u[g]||i;return n?r.createElement(h,o(o({ref:t},c),{},{components:n})):r.createElement(h,o({ref:t},c))}));function h(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var i=n.length,o=new Array(i);o[0]=g;var p={};for(var s in t)hasOwnProperty.call(t,s)&&(p[s]=t[s]);p.originalType=e,p[d]="string"==typeof e?e:a,o[1]=p;for(var l=2;l<i;l++)o[l]=n[l];return r.createElement.apply(null,o)}return r.createElement.apply(null,n)}g.displayName="MDXCreateElement"},92679:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>s,contentTitle:()=>o,default:()=>u,frontMatter:()=>i,metadata:()=>p,toc:()=>l});var r=n(58168),a=(n(96540),n(15680));const i={id:"implementing-the-provider-changes",title:"Implementing the provider changes"},o=void 0,p={unversionedId:"docs/workshops/ci-cd-legacy/workshop/implementing-the-provider-changes",id:"docs/workshops/ci-cd-legacy/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-legacy/workshop/05_implementing_the_provider_changes.md",sourceDirName:"docs/workshops/ci-cd-legacy/workshop",slug:"/docs/workshops/ci-cd-legacy/workshop/implementing-the-provider-changes",permalink:"/docs/workshops/ci-cd-legacy/workshop/implementing-the-provider-changes",draft:!1,editUrl:"https://github.com/pactflow/docs.pactflow.io/edit/master/website/docs/docs/workshops/ci-cd-legacy/workshop/05_implementing_the_provider_changes.md",tags:[],version:"current",lastUpdatedBy:"Yousaf Nabi",lastUpdatedAt:1674493712,formattedLastUpdatedAt:"Jan 23, 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-legacy/workshop/how-not-to-break-everything"},next:{title:"Strategies for verifying feature pacts",permalink:"/docs/workshops/ci-cd-legacy/workshop/verifying-feature-pacts"}},s={},l=[{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:l},d="wrapper";
1function u(e){let{components:t,...n}=e;return(0,a.yg)(d,(0,r.A)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,a.yg)("p",null,"The next step is to implement the changes that have been requested in the pact."),(0,a.yg)("ol",null,(0,a.yg)("li",{parentName:"ol"},(0,a.yg)("p",{parentName:"li"},"Open up the terminal for your provider project.")),(0,a.yg)("li",{parentName:"ol"},(0,a.yg)("p",{parentName:"li"},"Run ",(0,a.yg)("inlineCode",{parentName:"p"},"make test")," to make sure everything is passing before you start.")),(0,a.yg)("li",{parentName:"ol"},(0,a.yg)("p",{parentName:"li"},"Get the URL of the new pact:"),(0,a.yg)("ul",{parentName:"li"},(0,a.yg)("li",{parentName:"ul"},"Go to your PactFlow account, find the new pact on the consumer branch ",(0,a.yg)("inlineCode",{parentName:"li"},"feat/new-field"),' and click "VIEW PACT".'),(0,a.yg)("li",{parentName:"ul"},"In the top right, click the 3 dots and select ",(0,a.yg)("inlineCode",{parentName:"li"},"Copy pact URL for pactflow-example-consumer-legacy version xyz"),"."))),(0,a.yg)("li",{parentName:"ol"},(0,a.yg)("p",{parentName:"li"},"Run ",(0,a.yg)("inlineCode",{parentName:"p"},"PACT_URL=<PACT URL HERE> make test")," again. This test should correctly fail with the error ",(0,a.yg)("inlineCode",{parentName:"p"},'Could not find key "color"')," in the output."),(0,a.yg)("ul",{parentName:"li"},(0,a.yg)("li",{parentName:"ul"},'\ud83d\udc49 This little "verify a custom pact" trick works because of the code in in ',(0,a.yg)("inlineCode",{parentName:"li"},"src/product/product.pact.test.js"),' that switches between doing a "fetch pacts for these consumer version selectors" mode and a "verify the pact at the ',(0,a.yg)("inlineCode",{parentName:"li"},"$PACT_URL"),'" mode, based on whether or not the ',(0,a.yg)("inlineCode",{parentName:"li"},"$PACT_URL")," is set. The ",(0,a.yg)("inlineCode",{parentName:"li"},"$PACT_URL"),' code path is normally used 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.'))),(0,a.yg)("li",{parentName:"ol"},(0,a.yg)("p",{parentName:"li"},"Make the test pass by adding a ",(0,a.yg)("inlineCode",{parentName:"p"},"color")," field to ",(0,a.yg)("inlineCode",{parentName:"p"},"product/product.js"),", and adding the new color argument to the Product initialization lines in ",(0,a.yg)("inlineCode",{parentName:"p"},"product/product.repository.js")," and the provider states in ",(0,a.yg)("inlineCode",{parentName:"p"},"product/product.pact.test.js"),"."),(0,a.yg)("pre",{parentName:"li"},(0,a.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,a.yg)("pre",{parentName:"li"},(0,a.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,a.yg)("pre",{parentName:"li"},(0,a.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,a.yg)("li",{parentName:"ol"},(0,a.yg)("p",{parentName:"li"},"Run ",(0,a.yg)("inlineCode",{parentName:"p"},"PACT_URL=<PACT URL HERE> make test")," and you should have a passing test suite. \u2705")),(0,a.yg)("li",{parentName:"ol"},(0,a.yg)("p",{parentName:"li"},"Commit and push your changes."),(0,a.yg)("ol",{parentName:"li"},(0,a.yg)("li",{parentName:"ol"},(0,a.yg)("inlineCode",{parentName:"li"},"git add . && git commit -m 'feat: add color' && git push"))))),(0,a.yg)("h2",{id:"expected-state-by-the-end-of-this-step"},"Expected state by the end of this step"),(0,a.yg)("ul",null,(0,a.yg)("li",{parentName:"ul"},"A provider that implements the features required by the ",(0,a.yg)("inlineCode",{parentName:"li"},"feat/new-field")," pact on its ",(0,a.yg)("inlineCode",{parentName:"li"},"master")," branch."),(0,a.yg)("li",{parentName:"ul"},"A passing provider build in Github Actions."),(0,a.yg)("li",{parentName:"ul"},'The new version of the provider is "deployed" to production.'),
1(0,a.yg)("li",{parentName:"ul"},"A ",(0,a.yg)("inlineCode",{parentName:"li"},"feat/new-field")," pact with a failed verification result")),(0,a.yg)("h2",{id:"conclusion"},"Conclusion"),(0,a.yg)("p",null,"The ",(0,a.yg)("inlineCode",{parentName:"p"},"master")," provider is now compatible with the ",(0,a.yg)("inlineCode",{parentName:"p"},"feat/new-field")," pact. However, there is still a failing verification result published for the ",(0,a.yg)("inlineCode",{parentName:"p"},"feat/new-field")," pact, triggered by a webhook (contract requiring verification published) when the new pact was published."),(0,a.yg)("p",null,"We verified the Pact would pass against our providers main branch ",(0,a.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,a.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.