MCPcopy Create free account
hub / github.com/dave/blast / TestError

Function TestError

httpworker/httpworker_test.go:102–123  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

100}
101
102func TestError(t *testing.T) {
103 ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
104 w.WriteHeader(http.StatusInternalServerError)
105 w.Write([]byte("500 - error"))
106 }))
107 defer ts.Close()
108
109 payload := map[string]interface{}{
110 "method": "GET",
111 "url": ts.URL,
112 }
113 response, err := New().Send(context.Background(), payload)
114 expected := map[string]interface{}{
115 "status": 500,
116 }
117 if err == nil || err.Error() != "non 200 status" {
118 log.Fatalf("Unexpected error: %v", err)
119 }
120 if !reflect.DeepEqual(response, expected) {
121 t.Fatalf("Unexpected: %#v", response)
122 }
123}
124
125func TestErrorDecodingPayload(t *testing.T) {
126 ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))

Callers

nothing calls this directly

Calls 4

NewFunction · 0.70
WriteMethod · 0.65
SendMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected