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

Function TestAuthErrWithoutBody

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

Source from the content-addressed store, hash-verified

101}
102
103func TestAuthErrWithoutBody(t *testing.T) {
104 var called uint32
105 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
106 if r.URL.String() != "/test" {
107 w.WriteHeader(http.StatusNotFound)
108 return
109 }
110
111 atomic.AddUint32(&called, 1)
112 w.WriteHeader(401)
113 }))
114 defer srv.Close()
115
116 req, err := http.NewRequest("GET", srv.URL+"/test", nil)
117 assert.Nil(t, err)
118
119 c, _ := NewClient(nil)
120 _, err = c.Do(req)
121 assert.NotNil(t, err)
122 assert.True(t, errors.IsAuthError(err))
123 assert.True(t, strings.HasPrefix(err.Error(), "Authentication required: Authorization error:"), err.Error())
124 assert.EqualValues(t, 1, called)
125}
126
127func TestFatalWithoutBody(t *testing.T) {
128 var called uint32

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected