| 242 | } |
| 243 | |
| 244 | func TestDoPerformsSuppliedHTTPRequest(t *testing.T) { |
| 245 | t.Parallel() |
| 246 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 247 | fmt.Fprintln(w, "some data") |
| 248 | })) |
| 249 | defer ts.Close() |
| 250 | req, err := http.NewRequest(http.MethodGet, ts.URL, http.NoBody) |
| 251 | if err != nil { |
| 252 | t.Fatal(err) |
| 253 | } |
| 254 | want := "some data\n" |
| 255 | got, err := script.Do(req).String() |
| 256 | if err != nil { |
| 257 | t.Fatalf("unexpected error: %v", err) |
| 258 | } |
| 259 | if !cmp.Equal(want, got) { |
| 260 | t.Error(cmp.Diff(want, got)) |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | func TestEachLine_FiltersInputThroughSuppliedFunction(t *testing.T) { |
| 265 | t.Parallel() |