change body method; -> AutoSetBody; add method SetBody;
This commit is contained in:
parent
c4a12f9314
commit
8a6e29bc8a
|
@ -76,7 +76,7 @@ func TestSession_Post(t *testing.T) {
|
|||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
ses := NewSession()
|
||||
got, err := ses.Post("http://httpbin.org/post").SetBody(tt.args.params...).Execute()
|
||||
got, err := ses.Post("http://httpbin.org/post").AutoSetBody(tt.args.params...).Execute()
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Metchod error = %v", err)
|
||||
|
@ -127,7 +127,7 @@ func TestSession_Setparams(t *testing.T) {
|
|||
t.Run(tt.name, func(t *testing.T) {
|
||||
ses := NewSession()
|
||||
|
||||
got, err := ses.Post("http://httpbin.org/post").SetBody(tt.args.params...).Execute()
|
||||
got, err := ses.Post("http://httpbin.org/post").AutoSetBody(tt.args.params...).Execute()
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("Metchod error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
|
@ -169,7 +169,7 @@ func TestSession_PostUploadFile(t *testing.T) {
|
|||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
ses := NewSession()
|
||||
got, err := ses.Post("http://httpbin.org/post").SetBody(tt.args.params, TypeFormData).Execute()
|
||||
got, err := ses.Post("http://httpbin.org/post").AutoSetBody(tt.args.params, TypeFormData).Execute()
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Metchod error = %v", err)
|
||||
|
@ -213,7 +213,7 @@ func TestSession_Put(t *testing.T) {
|
|||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
ses := NewSession()
|
||||
got, err := ses.Put("http://httpbin.org/put").SetBody(tt.args.params, TypeFormData).Execute()
|
||||
got, err := ses.Put("http://httpbin.org/put").AutoSetBody(tt.args.params, TypeFormData).Execute()
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Metchod error = %v", err)
|
||||
|
@ -257,7 +257,7 @@ func TestSession_Patch(t *testing.T) {
|
|||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
ses := NewSession()
|
||||
got, err := ses.Patch("http://httpbin.org/patch").SetBody(tt.args.params, TypeFormData).Execute()
|
||||
got, err := ses.Patch("http://httpbin.org/patch").AutoSetBody(tt.args.params, TypeFormData).Execute()
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Metchod error = %v", err)
|
||||
|
|
13
workflow.go
13
workflow.go
|
@ -185,7 +185,18 @@ func (wf *Workflow) SetURLRawPath(path string) *Workflow {
|
|||
}
|
||||
|
||||
// SetBody 参数设置
|
||||
func (wf *Workflow) SetBody(params ...interface{}) *Workflow {
|
||||
func (wf *Workflow) SetBody(body IBody) *Workflow {
|
||||
wf.Body = body
|
||||
return wf
|
||||
}
|
||||
|
||||
// GetBody 参数设置
|
||||
func (wf *Workflow) GetBody(body IBody) IBody {
|
||||
return wf.Body
|
||||
}
|
||||
|
||||
// AutoSetBody 参数设置
|
||||
func (wf *Workflow) AutoSetBody(params ...interface{}) *Workflow {
|
||||
|
||||
if params != nil {
|
||||
plen := len(params)
|
||||
|
|
Loading…
Reference in New Issue
Block a user