Skip to content

prongbang/wiremock-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

Wiremock Example

  _      ___                        __  
 | | /| / (_)______ __ _  ___  ____/ /__
 | |/ |/ / / __/ -_)  ' \/ _ \/ __/  '_/
 |__/|__/_/_/  \__/_/_/_/\___/\__/_/\_\

 -> wiremock server started on :8000

  • Docker
$ docker-compose up
  • Golang
$ go get -u github.com/prongbang/wiremock/v2
$ wiremock

Server running

Login

Success

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"username":"admin","password":"pass"}' \
  http://localhost:8000/api/v1/login
  • Result
{"message": "success"}

Fail

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"username":"admin","password":"1234"}' \
  http://localhost:8000/api/v1/login
  • Result
{
  "errors":{
    "password":"The password not match"
  },
  "message":"validation error",
  "status":"error"
}

Create User

curl --request POST http://localhost:8000/api/v1/user
  • Result
{"message": "success"}

Get User by ID

curl http://localhost:8000/api/v1/user/1
  • Result
[
  {
    "id": 1,
    "name": "Leanne Graham",
    "username": "Bret",
    "email": "Sincere@april.biz",
    "address": {
      "street": "Kulas Light",
      "suite": "Apt. 556",
      "city": "Gwenborough",
      "zipcode": "92998-3874",
      "geo": {
        "lat": "-37.3159",
        "lng": "81.1496"
      }
    },
    "phone": "1-770-736-8031 x56442",
    "website": "hildegard.org",
    "company": {
      "name": "Romaguera-Crona",
      "catchPhrase": "Multi-layered client-server neural-net",
      "bs": "harness real-time e-markets"
    }
  }
]

About

Example Wiremock Minimal Mock your APIs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published