Mockturtle
is an easy configurable and generic mock server based on Vapor. The goal of Mockturtle
is to mock server results whereas the necessity for making source code changes (just because of the mock server) is kept to an absolute minimum.
The only difference between production and test code will be the base url
of your request (https://api.example.com/...
vs. http://localhost:8080/
) which may already vary for different environments (production, staging, testing
) and one (optional) additional HTTP Header x-mockturtle-state-identifier
to specify the state you want to mock.
- macOS
- Linux
- Docker
brew tap thepeaklab/tap
brew install mockturtle
# generate scenario json
docker run -i -v `pwd`:/folder -e FOLDER=/folder -e OUTPUT_FILE=/folder/output.json mockturtle:0.1.0
# serve
docker run -i -v `pwd`:/folder -e CONFIG=/folder/mock-config.yml --entrypoint="entrypoint-serve.sh" -p 8080:8080 mockturtle:0.1.0
For more information about mock-config.yml
see Docs/mock_config.md
version: "0.1.0"
routes:
- url: v1/auth/login
directory: login
method: POST
- url: v1/users
- directory: global/error_codes
For more information about state configurations see Docs/state_configuration.md
version: "0.1.0"
# Result for valid login
response:
code: 200
header:
Content-Type: "application/json"
body: >
{
"user": {
"name": "Peter",
"age": 19
}
}
# in the folder where your mock-config.yml lives
> mockturtle serve
Server starting on http://localhost:8080
You can modify your mock-config.yml
while the Mockturtle
server is running. File changes will be recognized and the server will update instantly.
Please submit an issue on GitHub.
This project is licensed under the terms of the MIT license. See the LICENSE file.