Skip to content
Permalink
Browse files

support patch method

  • Loading branch information...
txthinking committed Dec 6, 2017
1 parent a776c77 commit 0c7884ec9d27bfeb975e02b1b13331dcec03288a
Showing with 6 additions and 5 deletions.
  1. +1 −1 README.md
  2. +1 −1 case.go
  3. +1 −1 http.go
  4. +1 −1 main.go
  5. +2 −1 request.go
@@ -67,7 +67,7 @@ Frank contains there scopes:
* Must define `url` variable.
* **Request Score**
* The start line format `METHOD PATH [NAME]`, name is optionnal
* `Request Score` starts with a line that begins with `GET `, `HEAD `, `OPTIONS `, `POST `, `PUT ` or `DELETE `
* `Request Score` starts with a line that begins with `GET `, `HEAD `, `OPTIONS `, `POST `, `PUT `, `PATCH` or `DELETE `
* `PATH` must not have `?`, query and fragment
* Like this: `GET /path` or `GET /path Name this request`
* This score contains some predefined variables
@@ -116,7 +116,7 @@ func (c *Case) Run() error {
if err := v.Request.MakeQuery(); err != nil {
return e(v.Request, err)
}
if v.Request.Method == "POST" || v.Request.Method == "PUT" {
if v.Request.Method == "POST" || v.Request.Method == "PUT" || v.Request.Method == "PATCH" {
if err := v.Request.MakeBody(); err != nil {
return e(v.Request, err)
}
@@ -27,7 +27,7 @@ func NewHttpClient(url string) *HttpClient {
// Do a request
func (c *HttpClient) Do(req *Request) (*http.Response, error) {
var body io.Reader
if req.Method == "POST" || req.Method == "PUT" {
if req.Method == "POST" || req.Method == "PUT" || req.Method == "PATCH" {
body = bytes.NewReader(req.Body)
}
q := "?" + req.Query.Encode()
@@ -14,7 +14,7 @@ var markdown bool
func main() {
app := cli.NewApp()
app.Name = "Frank"
app.Version = "20171220"
app.Version = "20171221"
app.Usage = "Command line REST API automated testing tool"
app.Author = "Cloud"
app.Email = "cloud@txthinking.com"
@@ -34,6 +34,7 @@ func RequestBegin(s string) bool {
!strings.HasPrefix(s, "HEAD ") &&
!strings.HasPrefix(s, "OPTIONS ") &&
!strings.HasPrefix(s, "POST ") &&
!strings.HasPrefix(s, "PATCH ") &&
!strings.HasPrefix(s, "PUT ") {
return false
}
@@ -147,7 +148,7 @@ func (r *Request) MakeQuery() error {
if !ok {
i, ok := v.(int64)
if !ok {
return errors.New("Invalid query")
return errors.New("Invalid query 1")
}
s = strconv.Itoa(int(i))
}

0 comments on commit 0c7884e

Please sign in to comment.
You can’t perform that action at this time.