Skip to content
This repository was archived by the owner on Aug 3, 2022. It is now read-only.

Repository files navigation

smocky

CI codecov Docker Repository Github Release Go Report Card License

Installation

Go install

go install github.com/smockyio/smocky@latest

Homebrew

brew tap tuongaz/smocky-tap
brew install tuongaz/smocky-tap/smocky

Docker hub

docker pull tuongaz/smocky

docker run -ti tuongaz/smocky --version

Usage

CLI

smocky start --filename example/mock.yml

Go package

package example_test

import (
	"net/http"
	"testing"

	"github.com/smockyio/smocky/backend/pkg/smocky"
)

func Test_Example(t *testing.T) {
	srv := smocky.
		New().
		Get("/hello").
		Response(http.StatusOK, "hello world").
		Start(t)
	defer srv.Close()

	req, _ := http.NewRequest("GET", srv.URL, nil)
	client := &http.Client{}

	resp, err := client.Do(req)
}

func Test_Example_WithRules(t *testing.T) {
	srv := smocky.
		New().
		Get("/hello").
		When("cookie", "name", "equal", "Chocolate").
		Response(http.StatusOK, "hello world").
		Start(t)
	defer srv.Close()

	req, _ := http.NewRequest("GET", srv.URL, nil)
	client := &http.Client{}

	resp, err := client.Do(req)
}

About

Smocky is an easy to use HTTP mock server

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages