https://github.com/broothie/smock
a mock server
https://github.com/broothie/smock
http mock-server testing-tools
Last synced: 4 months ago
JSON representation
a mock server
- Host: GitHub
- URL: https://github.com/broothie/smock
- Owner: broothie
- License: gpl-3.0
- Created: 2018-12-07T22:22:27.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-06-29T17:29:33.000Z (almost 6 years ago)
- Last Synced: 2024-12-29T00:10:58.213Z (over 1 year ago)
- Topics: http, mock-server, testing-tools
- Language: Go
- Homepage:
- Size: 7.59 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `smock`
A server mock.
## Installation
### Mac
```bash
$ brew tap broothie/smock
$ brew install smock
```
### Releases
Releases are available on the [releases page](https://github.com/broothie/smock/releases).
### Source
You can also build from source of course if you have the Go toolchain installed and feel like doing that.
## Usage
Start a mock server:
```bash
$ smock -c 201 -h Content-Type=application/json -b '{"key": "value"}'
[smock] mock server @ http://localhost:9090
[smock] serving ui @ http://localhost:9091
```
then, in another terminal, hit the server:
```bash
$ curl -i localhost:9090
HTTP/1.1 201 Created
Content-Type: application/json
Date: Sat, 27 Jun 2020 23:39:43 GMT
Content-Length: 16
{"key": "value"}
```
### Proxying
Start smock proxied toward a uri:
```bash
$ smock proxy https://run.mocky.io
```
then:
```bash
$ curl -i localhost:9090/v3/06c38c1c-c6fa-4276-adaa-f3b3a878f64e
HTTP/1.1 418 I'm a teapot
Content-Length: 16
Content-Type: application/json; charset=UTF-8
Date: Sat, 27 Jun 2020 23:42:45 GMT
Sozu-Id: 3f328940-74ca-4255-aa80-429418cd6f98
X-Foo: bar
{"key": "value"}
```
### UI
And check it out - there's even a UI where you can see your requests coming through in real time!

## All Options
```bash
$ smock --help-long
usage: smock [] [ ...]
Flags:
--help Show context-sensitive help (also try --help-long and
--help-man).
-p, --port=9090 port to run server mock on
-u, --uiport=9091 port to run ui on
--no-ui disable ui
-c, --code=200 response status code
-h, --header=HEADER ... response headers
-b, --body="" response body
Commands:
help [...]
Show help.
version
print smock version
mock []
mock response
-c, --code=200 response status code
-h, --header=HEADER ... response headers
-b, --body="" response body
proxy
reverse proxy to target url
```
### TODO
- [ ] Stubs
- [ ] Clean up errors
- [ ] Retrofit JS
- [ ] Show proxied request info in UI