Skip to content

Mockturtle is an easy configurable and generic mock server based on Vapor

License

Notifications You must be signed in to change notification settings

thepeaklab/mockturtle

Repository files navigation

Mockturtle

Build Status Swift Version PackageManager License Twitter: @thepeaklab

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. https://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.

Available for

  • macOS
  • Linux
  • Docker

Homebrew

brew tap thepeaklab/tap
brew install mockturtle

Docker

# 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

Mock Configuration File

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

State Configuration

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
      }
    }

Serve

# in the folder where your mock-config.yml lives
> mockturtle serve
Server starting on https://localhost:8080

File Watch

You can modify your mock-config.yml while the Mockturtle server is running. File changes will be recognized and the server will update instantly.

Need Help?

Please submit an issue on GitHub.

License

This project is licensed under the terms of the MIT license. See the LICENSE file.

About

Mockturtle is an easy configurable and generic mock server based on Vapor

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •