forgot to run gofmt
Stephen Young
7 years ago
347 | 347 | const case22_send_byte_int = "/send_byte_int" |
348 | 348 | const case22_send_byte_int_pointer = "/send_byte_int_pointer" |
349 | 349 | const case23_send_duplicate_query_params = "/send_duplicate_query_params" |
350 | const case24_send_query_and_request_body = "/send_query_and_request_body" | |
350 | const case24_send_query_and_request_body = "/send_query_and_request_body" | |
351 | 351 | |
352 | 352 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
353 | 353 | // check method is POST before going to check other features |
481 | 481 | if values["param"][0] != "4" || values["param"][1] != "3" || values["param"][2] != "2" || values["param"][3] != "1" { |
482 | 482 | t.Error("Expected Body with 4 params and values", "| but got", sbody) |
483 | 483 | } |
484 | case case24_send_query_and_request_body: | |
485 | t.Logf("case %v ", case24_send_query_and_request_body) | |
486 | defer r.Body.Close() | |
487 | body, _ := ioutil.ReadAll(r.Body) | |
484 | case case24_send_query_and_request_body: | |
485 | t.Logf("case %v ", case24_send_query_and_request_body) | |
486 | defer r.Body.Close() | |
487 | body, _ := ioutil.ReadAll(r.Body) | |
488 | 488 | sbody := string(body) |
489 | if sbody != `{"name":"jkbbwr"}` { | |
489 | if sbody != `{"name":"jkbbwr"}` { | |
490 | 490 | t.Error(`Expected Body "{"name":"jkbbwr"}"`, "| but got", sbody) |
491 | 491 | } |
492 | 492 | |
493 | v := r.URL.Query() | |
494 | if v["test"][0] != "true" { | |
493 | v := r.URL.Query() | |
494 | if v["test"][0] != "true" { | |
495 | 495 | t.Error("Expected test:true", "| but got", v["test"][0]) |
496 | 496 | } |
497 | 497 | } |
646 | 646 | Send("param=3¶m=4"). |
647 | 647 | End() |
648 | 648 | |
649 | data24 := struct{Name string `json:"name"`}{"jkbbwr"} | |
650 | New().Post(ts.URL + case24_send_query_and_request_body). | |
649 | data24 := struct { | |
650 | Name string `json:"name"` | |
651 | }{"jkbbwr"} | |
652 | New().Post(ts.URL + case24_send_query_and_request_body). | |
651 | 653 | Query("test=true"). |
652 | 654 | Send(data24). |
653 | 655 | End() |
1601 | 1603 | defer ts.Close() |
1602 | 1604 | |
1603 | 1605 | New().Get(ts.URL).AddCookies([]*http.Cookie{ |
1604 | &http.Cookie{Name: "API-Cookie-Name1", Value: "api-cookie-value1"}, | |
1605 | &http.Cookie{Name: "API-Cookie-Name2", Value: "api-cookie-value2"}, | |
1606 | {Name: "API-Cookie-Name1", Value: "api-cookie-value1"}, | |
1607 | {Name: "API-Cookie-Name2", Value: "api-cookie-value2"}, | |
1606 | 1608 | }).End() |
1607 | 1609 | } |
1608 | 1610 |