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

Function TestGetMakesHTTPGetRequestToGivenURL

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

Source from the content-addressed store, hash-verified

642}
643
644func TestGetMakesHTTPGetRequestToGivenURL(t *testing.T) {
645 t.Parallel()
646 ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
647 if r.Method != http.MethodGet {
648 t.Fatalf("want HTTP method GET, got %q", r.Method)
649 }
650 fmt.Fprintln(w, "some data")
651 }))
652 defer ts.Close()
653 want := "some data\n"
654 got, err := script.Get(ts.URL).String()
655 if err != nil {
656 t.Fatalf("unexpected error: %v", err)
657 }
658 if !cmp.Equal(want, got) {
659 t.Error(cmp.Diff(want, got))
660 }
661}
662
663func TestGetSetsErrorStatusWhenHTTPResponseStatusIsNotOK(t *testing.T) {
664 t.Parallel()

Callers

nothing calls this directly

Calls 4

GetFunction · 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…