📡 mock is a simple, cross-platform, cli app to simulate HTTP-based APIs.

Project Logo

mock

📡 mock is a simple, cross-platform, cli app to simulate HTTP-based APIs.

GitHub Downloads Latest Release Build Status Contributions Welcome

About mock

Mock allows you to spin up a local http server based of a .mock.yaml file. Preferably mock is used per project and a .mock.yaml file is created at the root of a repository.

Installation

Binaries

If you prefer grabbing mock its binaries, download the latest from the the GitHub releases page.

Brew

❯ brew tap bschaatsbergen/mock
❯ brew install mock

Chocolatey (Not supported yet)

❯ choco install mock

Usage

Running mock is very easy, by simply running the below command you tell mock to translate the .mock.yaml in the current working directory to an http server that by default runs under port 7070. Use the -p flag to change the default port.

❯ mock serve

📝 using config file: .mock.yaml
📡 starting mock on :7070, exit to stop

To bring you up to speed, we allow you to run the below command in order to generate an exampe .mock.yaml in the current working directory.

❯ mock init

🎉 generated '.mock.yaml' in: /home/bruno/Projects/MyNewApi

The generated .mock.yaml configuration looks as following. It's made up of a list of endpoints, each containing a resource path, http method, response and http status code.

# Example .mock.yaml config
Endpoints:
  - Resource: /city/1
    Method: GET
    Response: '{ "Id": 1, "Name": "Albuquerque", "Population": 559.374, "State": "New Mexico" }'
    StatusCode: 200

  - Resource: /city
    Method: POST
    Response: '{ "Name": "Albuquerque", "Population": 559.374, "State": "New Mexico" }'
    statusCode: 200

  - Resource: /city/1
    Method: PUT
    Response: '{ "Id": 1, "Name": "Albuquerque", "Population": 601.255, "State": "New Mexico" }'
    StatusCode: 200

  - Resource: /city/1
    Method: DELETE
    StatusCode: 204

After running mock serve you can verify whether the routes are available

❯ curl -i -X GET 'http://localhost:7070/city/1'
HTTP/1.1 200 OK
Content-Type: application/json
Date: Tue, 19 Oct 2021 13:25:47 GMT
Content-Length: 80

{ "Id": 1, "Name": "Albuquerque", "Population": 559.374, "State": "New Mexico" }

License

This project is licensed under the MIT License - see the LICENSE file for details.

Owner
Similar Resources

Extremely flexible golang deep comparison, extends the go testing package and tests HTTP APIs

Extremely flexible golang deep comparison, extends the go testing package and tests HTTP APIs

go-testdeep Extremely flexible golang deep comparison, extends the go testing package. Latest news Synopsis Description Installation Functions Availab

Dec 22, 2022

Sql mock driver for golang to test database interactions

Sql driver mock for Golang sqlmock is a mock library implementing sql/driver. Which has one and only purpose - to simulate any sql driver behavior in

Dec 31, 2022

Powerful mock generation tool for Go programming language

Summary Minimock generates mocks out of Go interface declarations. The main features of minimock are: It generates statically typed mocks and helpers.

Dec 17, 2022

ESME is a go library that allows you to mock a RESTful service by defining the configuration in json format

ESME is a go library that allows you to mock a RESTful service by defining the configuration in json format. This service can then simply be consumed by any client to get the expected response.

Mar 2, 2021

mockery - A mock code autogenerator for Golang

mockery - A mock code autogenerator for Golang

mockery - A mock code autogenerator for Golang

Jan 8, 2023

Create your own mock server with just a JSON file!

Gmocker Run a blazing fast mock server in just seconds! 🚀 All you need is to make a json file that contains path and response mapping. See an example

Dec 21, 2022

Create your own blazing fast mock server with just a JSON file!

Gmocker Run a blazing fast mock server in just seconds! 🚀 All you need is to make a json file that contains path and response mapping. See an example

Dec 21, 2022

Apple Push Notification service (APNs) mock server

APNs Mock Server Server

Dec 8, 2022

Completely type-safe compile-time mock generator for Go

Mockc Mockc is a completely type-safe compile-time mock generator for Go. You can use it just by writing the mock generators with mockc.Implement() or

Aug 25, 2022
Vault mock - Mock of Hashicorp Vault used for unit testing

vault_mock Mock of Hashicorp Vault used for unit testing Notice This is a person

Jan 19, 2022
Mock-the-fck - Mock exercise for human

Mock the fck Originally, Mockery-example Example case for mockery issue #128 fil

Jan 21, 2022
HTTP mock for Golang: record and replay HTTP/HTTPS interactions for offline testing

govcr A Word Of Warning I'm in the process of partly rewriting govcr to offer better support for cassette mutations. This is necessary because when I

Dec 28, 2022
Simple mock program to set charging rate of a battery instance based on the national grid intensity api

Charger Simple mock program to set charging rate of a battery instance based on the national grid intensity api. Steps to get up and running I have cr

Nov 16, 2021
Fast cross-platform HTTP benchmarking tool written in Go

bombardier bombardier is a HTTP(S) benchmarking tool. It is written in Go programming language and uses excellent fasthttp instead of Go's default htt

Dec 31, 2022
Mock object for Go http.ResponseWriter

mockhttp -- Go package for unit testing HTTP serving Unit testing HTTP services written in Go means you need to call their ServeHTTP receiver. For thi

Sep 27, 2022
A basic lightweight HTTP client for Go with included mock features.

A basic lightweight HTTP client for Go with included mock features. Features Support almost all http method like G

May 2, 2022
A tool that integrates SQL, HTTP,interface,Redis mock

Mockit 目标:将mock变得简单,让代码维护变得容易 分支介绍 main 主分支,覆盖了单元测试 light 轻分支,去除了单元测试,简化了依赖项,方便其他团队使用 常见Mock难点 不同中间件,mock库设计模式不一致,学习代价高,差异化明显 mock方案强依赖服务端,无法灵活解耦 单元测试

Sep 22, 2022
Check-load - Simple cross-platform load average check

Sensu load average check Table of Contents Overview Usage examples Configuration

Jun 16, 2022
A simple mock server configurable via JSON, built using GoLang.
A simple mock server configurable via JSON, built using GoLang.

GoMock Server A simple mock server configurable via JSON, built using GoLang. How To A file name endpoint.json must be placed in the context root, wit

Nov 19, 2022