Categorygithub.com/pactflow/example-provider-golang
modulepackage
0.0.0-20240927152020-d79911b22891
Repository: https://github.com/pactflow/example-provider-golang.git
Documentation: pkg.go.dev

# README

Example Provider

Build

Can I deploy Status

This is an example of a (Gin-based) Golang provider that uses Pact, PactFlow and GitHub Actions to ensure that it is compatible with the expectations its consumers have of it.

The project uses a Makefile to simulate a very simple build pipeline with two stages - test and deploy.

It is using a public tenant on PactFlow, which you can access here using the credentials dXfltyFMgNOFZAxr8io9wJ37iUpY42M/O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1. The latest version of the Example Consumer/Example Provider pact is published here.

Pre-Requisites

In order to use pact-go v2, you must install pact ffi system libraries to your machine.

make install

In order to use the pact cli tools, which interact with a pact broker, the Ruby standalone binaries must be installed, the following script will download them and add them to your system PATH

make install_cli

Usage

See the PactFlow CI/CD Workshop.

make fake_ci

# Functions

GetProduct fetches a product if authenticated and exists.

# Variables

ErrEmpty is returned when input string is empty.
ErrNotFound represents a resource not found (404).
ErrUnauthorized represents a Forbidden (403).

# Structs

Product is the domain object.
ProductRepository is an in-memory product database.