smocky
Installation
Go install
go install github.com/smockyio/smocky@latest
Homebrew
brew tap tuongaz/smocky-tapbrew install tuongaz/smocky-tap/smocky
Docker hub
docker pull tuongaz/smockydocker run -ti tuongaz/smocky --version
Usage
CLI
smocky start --filename example/mock.yml
Go package
package example_testimport ("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)}