Skip to content

Commit

Permalink
resp.Body/matchBody; match with nameCtx
Browse files Browse the repository at this point in the history
  • Loading branch information
xushiwei committed Jan 30, 2024
1 parent 49cdbad commit d92d737
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 79 deletions.
33 changes: 19 additions & 14 deletions ytest/case.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,77 +172,82 @@ func (p *Case) T() CaseT {
}

// Req create a new request given a method and url.
func (p *Case) Req(method, url string) *Request {
func (p *Case) Req__0(method, url string) *Request {
req := newRequest(p, method, url)
p.Request = req
return req
}

// Req returns current request object.
func (p *Case) Req__1() *Request {
return p.Request
}

// Get is a shortcut for Req(http.MethodGet, url)
func (p *Case) Get(url string) *Request {
return p.Req(http.MethodGet, url)
return p.Req__0(http.MethodGet, url)
}

// Post is a shortcut for Req(http.MethodPost, url)
func (p *Case) Post(url string) *Request {
return p.Req(http.MethodPost, url)
return p.Req__0(http.MethodPost, url)
}

// Head is a shortcut for Req(http.MethodHead, url)
func (p *Case) Head(url string) *Request {
return p.Req(http.MethodHead, url)
return p.Req__0(http.MethodHead, url)
}

// Put is a shortcut for Req(http.MethodPut, url)
func (p *Case) Put(url string) *Request {
return p.Req(http.MethodPut, url)
return p.Req__0(http.MethodPut, url)
}

// Options is a shortcut for Req(http.MethodOptions, url)
func (p *Case) Options(url string) *Request {
return p.Req(http.MethodOptions, url)
return p.Req__0(http.MethodOptions, url)
}

// Patch is a shortcut for Req(http.MethodPatch, url)
func (p *Case) Patch(url string) *Request {
return p.Req(http.MethodPatch, url)
return p.Req__0(http.MethodPatch, url)
}

// -----------------------------------------------------------------------------

// GET is a shortcut for Req(http.MethodGet, url)
func (p *Case) GET(url string) *Request {
return p.Req(http.MethodGet, url)
return p.Req__0(http.MethodGet, url)
}

// POST is a shortcut for Req(http.MethodPost, url)
func (p *Case) POST(url string) *Request {
return p.Req(http.MethodPost, url)
return p.Req__0(http.MethodPost, url)
}

// HEAD is a shortcut for Req(http.MethodHead, url)
func (p *Case) HEAD(url string) *Request {
return p.Req(http.MethodHead, url)
return p.Req__0(http.MethodHead, url)
}

// PUT is a shortcut for Req(http.MethodPut, url)
func (p *Case) PUT(url string) *Request {
return p.Req(http.MethodPut, url)
return p.Req__0(http.MethodPut, url)
}

// OPTIONS is a shortcut for Req(http.MethodOptions, url)
func (p *Case) OPTIONS(url string) *Request {
return p.Req(http.MethodOptions, url)
return p.Req__0(http.MethodOptions, url)
}

// PATCH is a shortcut for Req(http.MethodPatch, url)
func (p *Case) PATCH(url string) *Request {
return p.Req(http.MethodPatch, url)
return p.Req__0(http.MethodPatch, url)
}

// DELETE is a shortcut for Req(http.MethodDelete, url)
func (p *Case) DELETE(url string) *Request {
return p.Req(http.MethodDelete, url)
return p.Req__0(http.MethodDelete, url)
}

// -----------------------------------------------------------------------------
2 changes: 1 addition & 1 deletion ytest/demo/foo/bar_ytest.gox
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ run "get /p/$id", => {
get "http://foo.com/p/${id}"
ret 200
json {
"id": "12",
"id": id,
}
}
2 changes: 1 addition & 1 deletion ytest/demo/foo/foo_ytest.gox
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ run "get /p/$id", => {
get "http://foo.com/p/${id}"
ret 200
json {
"id": "12",
"id": id,
}
}
4 changes: 2 additions & 2 deletions ytest/demo/foo/gop_autogen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (this *case_bar) Main() {
//line ytest/demo/foo/bar_ytest.gox:6:1
this.RetWith(200)
//line ytest/demo/foo/bar_ytest.gox:7:1
this.Json(map[string]string{"id": "12"})
this.Json(map[string]string{"id": id})
})
}
//line ytest/demo/foo/foo_ytest.gox:1
Expand All @@ -40,7 +40,7 @@ func (this *case_foo) Main() {
//line ytest/demo/foo/foo_ytest.gox:6:1
this.RetWith(200)
//line ytest/demo/foo/foo_ytest.gox:7:1
this.Json(map[string]string{"id": "12"})
this.Json(map[string]string{"id": id})
})
}
func Test_bar(t *testing.T) {
Expand Down
Loading

0 comments on commit d92d737

Please sign in to comment.