| 69 | } |
| 70 | |
| 71 | func TestHeaders(t *testing.T) { |
| 72 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 73 | if r.Method != "GET" { |
| 74 | t.Errorf("Unexpected method: %s", r.Method) |
| 75 | } |
| 76 | if r.Header.Get("a") != "b" || r.Header.Get("c") != "d" { |
| 77 | t.Errorf("Unexpected: a=%s, c=%s", r.Header.Get("a"), r.Header.Get("c")) |
| 78 | } |
| 79 | })) |
| 80 | defer ts.Close() |
| 81 | |
| 82 | payload := map[string]interface{}{ |
| 83 | "method": "GET", |
| 84 | "url": ts.URL, |
| 85 | "headers": map[string]string{ |
| 86 | "a": "b", |
| 87 | "c": "d", |
| 88 | }, |
| 89 | } |
| 90 | response, err := New().Send(context.Background(), payload) |
| 91 | expected := map[string]interface{}{ |
| 92 | "status": 200, |
| 93 | } |
| 94 | if err != nil { |
| 95 | log.Fatal(err) |
| 96 | } |
| 97 | if !reflect.DeepEqual(response, expected) { |
| 98 | t.Fatalf("Unexpected: %#v", response) |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | func TestError(t *testing.T) { |
| 103 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |