MCPcopy
hub / github.com/cloudflare/cloudflared / TestStaticHTTPStatus

Function TestStaticHTTPStatus

ingress/rule_test.go:172–193  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

170}
171
172func TestStaticHTTPStatus(t *testing.T) {
173 o := newStatusCode(404)
174 buf := make([]byte, 100)
175
176 sendReq := func() {
177 resp, err := o.RoundTrip(nil)
178 require.NoError(t, err)
179 _, err = resp.Body.Read(buf)
180 require.Equal(t, io.EOF, err)
181 require.NoError(t, resp.Body.Close())
182 require.Equal(t, 404, resp.StatusCode)
183
184 resp, err = o.RoundTrip(nil)
185 require.NoError(t, err)
186 w := httptest.NewRecorder()
187 n, err := io.Copy(w, resp.Body)
188 require.NoError(t, err)
189 require.Equal(t, int64(0), n)
190 }
191 sendReq()
192 sendReq()
193}
194
195func TestMarshalJSON(t *testing.T) {
196 localhost8000 := MustParseURL(t, "https://localhost:8000")

Callers

nothing calls this directly

Calls 5

newStatusCodeFunction · 0.85
EqualMethod · 0.65
CloseMethod · 0.65
RoundTripMethod · 0.45
ReadMethod · 0.45

Tested by

no test coverage detected