MCPcopy
hub / github.com/git-lfs/git-lfs / TestFatalWithoutBody

Function TestFatalWithoutBody

lfsapi/response_test.go:127–149  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

125}
126
127func TestFatalWithoutBody(t *testing.T) {
128 var called uint32
129 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
130 if r.URL.String() != "/test" {
131 w.WriteHeader(http.StatusNotFound)
132 return
133 }
134
135 atomic.AddUint32(&called, 1)
136 w.WriteHeader(500)
137 }))
138 defer srv.Close()
139
140 req, err := http.NewRequest("GET", srv.URL+"/test", nil)
141 assert.Nil(t, err)
142
143 c, _ := NewClient(nil)
144 _, err = c.Do(req)
145 assert.NotNil(t, err)
146 assert.True(t, errors.IsFatalError(err))
147 assert.True(t, strings.HasPrefix(err.Error(), "Fatal error: Server error:"), err.Error())
148 assert.EqualValues(t, 1, called)
149}
150
151func TestWithNonFatal500WithoutBody(t *testing.T) {
152 c, _ := NewClient(nil)

Callers

nothing calls this directly

Calls 7

DoMethod · 0.95
IsFatalErrorFunction · 0.92
NewClientFunction · 0.70
StringMethod · 0.65
CloseMethod · 0.65
ErrorMethod · 0.65
NewRequestMethod · 0.45

Tested by

no test coverage detected