Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resp.Body/matchBody; match with nameCtx #43

Merged
merged 3 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/basic/foo_ytest.gox
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,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/basic/gop_autogen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (this *case_foo) Main() {
//line ytest/demo/basic/foo_ytest.gox:8:1
this.RetWith(200)
//line ytest/demo/basic/foo_ytest.gox:9:1
this.Json(map[string]string{"id": "12"})
this.Json(map[string]string{"id": id})
})
}
func Test_foo(t *testing.T) {
Expand Down
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