| 647 | } |
| 648 | |
| 649 | func TestAddQuery(t *testing.T) { |
| 650 | req := &request{path: "/foo"} |
| 651 | if err := req.addQuery("bar", "123"); err != nil { |
| 652 | t.Fatal(err) |
| 653 | } |
| 654 | if exp := "/foo?bar=123"; req.path != exp { |
| 655 | t.Fatalf("unexpected path %q, expected %q", req.path, exp) |
| 656 | } |
| 657 | if err := req.addQuery("baz", "456"); err != nil { |
| 658 | t.Fatal(err) |
| 659 | } |
| 660 | if exp := "/foo?bar=123&baz=456"; req.path != exp { |
| 661 | t.Fatalf("unexpected path %q, expected %q", req.path, exp) |
| 662 | } |
| 663 | if err := req.addQuery("baz", "789"); err != nil { |
| 664 | t.Fatal(err) |
| 665 | } |
| 666 | if exp := "/foo?bar=123&baz=456&baz=789"; req.path != exp { |
| 667 | t.Fatalf("unexpected path %q, expected %q", req.path, exp) |
| 668 | } |
| 669 | } |
| 670 | |
| 671 | func TestRequestSanitize(t *testing.T) { |
| 672 | tests := []struct { |