MCPcopy
hub / github.com/bitfield/script / TestDoPerformsSuppliedHTTPRequest

Function TestDoPerformsSuppliedHTTPRequest

script_test.go:244–262  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

242}
243
244func 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
264func TestEachLine_FiltersInputThroughSuppliedFunction(t *testing.T) {
265 t.Parallel()

Callers

nothing calls this directly

Calls 4

DoFunction · 0.92
StringMethod · 0.80
ErrorMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…