Debian Codegraph @

lfsapi/response_test.go

raw symbols SCIP
1 package lfsapiscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/
2
3 import (
4 "net/httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/"
5 "net/http/httptestscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/"
6 "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/"
7 "sync/atomicscip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/"
8 "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/"
9
10 "github.com/git-lfs/git-lfs/v3/errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/"
11 "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/"
12 )
13
14 func TestAuthErrWithBodyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/TestAuthErrWithBody().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
15 var called uint32
16 srv := httptestscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/.NewServerscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/NewServer().(httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.HandlerFuncscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/HandlerFunc#(func(w httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.ResponseWriterscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#, r *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#) {
17 if r.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#URL..Stringscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#String().() != "/test" {
18 w.WriteHeaderscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#WriteHeader().(httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.StatusNotFoundscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/StatusNotFound.)
19 return
20 }
21
22 atomicscip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/.AddUint32scip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/AddUint32().(&called, 1)
23 w.Headerscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#Header().().Setscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Header#Set().("Content-Type", "application/json")
24 w.WriteHeaderscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#WriteHeader().(401)
25 w.Writescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#Write().([]byte(`{"message":"custom auth error"}`))
26 }))
27 defer srv.Closescip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/Server#Close().()
28
29 req, err := httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.NewRequestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/NewRequest().("GET", srv.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/Server#URL.+"/test", nil)
30 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, err)
31
32 c := NewClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/NewClient().(nil)
33 _, err = c.Doscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Do().(req)
34 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/NotNil().(t, err)
35 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/True().(t, errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.IsAuthErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/IsAuthError().(err))
36 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, "Authentication required: custom auth error", err.Error())
37 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.EqualValuesscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/EqualValues().(t, 1, called)
38 }
39
40 func TestFatalWithBodyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/TestFatalWithBody().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
41 var called uint32
42 srv := httptestscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/.NewServerscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/NewServer().(httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.HandlerFuncscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/HandlerFunc#(func(w httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.ResponseWriterscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#, r *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#) {
43 if r.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#URL..Stringscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#String().() != "/test" {
44 w.WriteHeaderscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#WriteHeader().(httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.StatusNotFoundscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/StatusNotFound.)
45 return
46 }
47
48 atomicscip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/.AddUint32scip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/AddUint32().(&called, 1)
49 w.Headerscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#Header().().Setscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Header#Set().("Content-Type", "application/json")
50 w.WriteHeaderscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#WriteHeader().(500)
51 w.Writescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#Write().([]byte(`{"message":"custom fatal error"}`))
52 }))
53 defer srv.Closescip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/Server#Close().()
54
55 req, err := httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.NewRequestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/NewRequest().("GET", srv.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/Server#URL.+"/test", nil)
56 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, err)
57
58 c := NewClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/NewClient().(nil)
59 _, err = c.Doscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Do().(req)
60 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/NotNil().(t, err)
61 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/True().(t, errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.IsFatalErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/IsFatalError().(err))
62 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, "Fatal error: custom fatal error", err.Error())
63 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.EqualValuesscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/EqualValues().(t, 1, called)
64 }
65
66 func TestWithNonFatal500WithBodyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/TestWithNonFatal500WithBody().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
67 c := NewClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/NewClient().(nil)
68
69 var called uint32
70
71 nonFatalCodes := map[int]string{
72 501: "custom 501 error",
73 507: "custom 507 error",
74 509: "custom 509 error",
75 }
76
77 for nonFatalCode, expectedErr := range nonFatalCodes {
78 srv := httptestscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/.NewServerscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/NewServer().(httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.HandlerFuncscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/HandlerFunc#(func(w httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.ResponseWriterscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#, r *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#) {
79 if r.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#URL..Stringscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#String().() != "/test" {
80 w.WriteHeaderscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#WriteHeader().(httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.StatusNotFoundscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/StatusNotFound.)
81 return
82 }
83
84 atomicscip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/.AddUint32scip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/AddUint32().(&called, 1)
85 w.Headerscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#Header().().Setscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Header#Set().("Content-Type", "application/json")
86 w.WriteHeaderscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#WriteHeader().(nonFatalCode)
87 w.Writescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#Write().([]byte(`{"message":"` + expectedErr + `"}`))
88 }))
89
90 req, err := httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.NewRequestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/NewRequest().("GET", srv.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/Server#URL.+"/test", nil)
91 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, err)
92
93 _, err = c.Doscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Do().(req)
94 t.Logfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Logf().("non fatal code %d", nonFatalCode)
95 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/NotNil().(t, err)
96 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, expectedErr, err.Error())
97 srv.Closescip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/Server#Close().()
98 }
99
100 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.EqualValuesscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/EqualValues().(t, 3, called)
101 }
102
103 func TestAuthErrWithoutBodyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/TestAuthErrWithoutBody().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
104 var called uint32
105 srv := httptestscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/.NewServerscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/NewServer().(httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.HandlerFuncscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/HandlerFunc#(func(w httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.ResponseWriterscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#, r *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#) {
106 if r.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#URL..Stringscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#String().() != "/test" {
107 w.WriteHeaderscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#WriteHeader().(httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.StatusNotFoundscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/StatusNotFound.)
108 return
109 }
110
111 atomicscip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/.AddUint32scip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/AddUint32().(&called, 1)
112 w.WriteHeaderscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#WriteHeader().(401)
113 }))
114 defer srv.Closescip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/Server#Close().()
115
116 req, err := httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.NewRequestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/NewRequest().("GET", srv.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/Server#URL.+"/test", nil)
117 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, err)
118
119 c := NewClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/NewClient().(nil)
120 _, err = c.Doscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Do().(req)
121 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/NotNil().(t, err)
122 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/True().(t, errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.IsAuthErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/IsAuthError().(err))
123 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/True().(t, stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25.0 strings/HasPrefix().(err.Error(), "Authentication required: Authorization error:"), err.Error())
124 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.EqualValuesscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/EqualValues().(t, 1, called)
125 }
126
127 func TestFatalWithoutBodyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/TestFatalWithoutBody().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
128 var called uint32
129 srv := httptestscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/.NewServerscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/NewServer().(httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.HandlerFuncscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/HandlerFunc#(func(w httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.ResponseWriterscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#, r *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#) {
130 if r.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#URL..Stringscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#String().() != "/test" {
131 w.WriteHeaderscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#WriteHeader().(httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.StatusNotFoundscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/StatusNotFound.)
132 return
133 }
134
135 atomicscip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/.AddUint32scip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/AddUint32().(&called, 1)
136 w.WriteHeaderscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#WriteHeader().(500)
137 }))
138 defer srv.Closescip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/Server#Close().()
139
140 req, err := httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.NewRequestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/NewRequest().("GET", srv.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/Server#URL.+"/test", nil)
141 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, err)
142
143 c := NewClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/NewClient().(nil)
144 _, err = c.Doscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Do().(req)
145 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/NotNil().(t, err)
146 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/True().(t, errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.IsFatalErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/IsFatalError().(err))
147 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/True().(t, stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25.0 strings/HasPrefix().(err.Error(), "Fatal error: Server error:"), err.Error())
148 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.EqualValuesscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/EqualValues().(t, 1, called)
149 }
150
151 func TestWithNonFatal500WithoutBodyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/TestWithNonFatal500WithoutBody().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
152 c := NewClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/NewClient().(nil)
153
154 var called uint32
155
156 nonFatalCodes := map[int]string{
157 501: "Not Implemented:",
158 507: "Insufficient server storage:",
159 509: "Bandwidth limit exceeded:",
160 }
161
162 for nonFatalCode, errPrefix := range nonFatalCodes {
163 srv := httptestscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/.NewServerscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/NewServer().(httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.HandlerFuncscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/HandlerFunc#(func(w httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.ResponseWriterscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#, r *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#) {
164 if r.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#URL..Stringscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#String().() != "/test" {
165 w.WriteHeaderscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#WriteHeader().(httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.StatusNotFoundscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/StatusNotFound.)
166 return
167 }
168
169 atomicscip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/.AddUint32scip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/AddUint32().(&called, 1)
170 w.WriteHeaderscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#WriteHeader().(nonFatalCode)
171 }))
172
173 req, err := httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.NewRequestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/NewRequest().("GET", srv.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/Server#URL.+"/test", nil)
174 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, err)
175
176 _, err = c.Doscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Do().(req)
177 t.Logfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Logf().("non fatal code %d", nonFatalCode)
178 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/NotNil().(t, err)
179 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/True().(t, stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25.0 strings/HasPrefix().(err.Error(), errPrefix))
180 srv.Closescip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/Server#Close().()
181 }
182
183 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.EqualValuesscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/EqualValues().(t, 3, called)
184 }
185
186 func TestRateLimitedWithBodyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/TestRateLimitedWithBody().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
187 c := NewClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/NewClient().(nil)
188
189 var called uint32
190
191 tests := []struct {
192 name string
193 statusCode int
194 retryAfter string
195 expectedRetriable bool
196 expectedRetryLater bool
197 serverMessage string
198 }{
199 {
200 name: "429 without Retry-After",
201 statusCode: 429,
202 expectedRetriable: true,
203 serverMessage: "custom 429 error",
204 },
205 {
206 name: "429 with Retry-After",
207 statusCode: 429,
208 retryAfter: "60",
209 expectedRetryLater: true,
210 serverMessage: "custom 429 error",
211 },
212 }
213
214 for _, tt := range tests {
215 t.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Run().(tt.name, func(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
216 srv := httptestscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/.NewServerscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/NewServer().(httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.HandlerFuncscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/HandlerFunc#(func(w httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.ResponseWriterscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#, r *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#) {
217 if r.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#URL..Stringscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#String().() != "/test" {
218 w.WriteHeaderscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#WriteHeader().(httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.StatusNotFoundscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/StatusNotFound.)
219 return
220 }
221
222 atomicscip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/.AddUint32scip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/AddUint32().(&called, 1)
223 w.Headerscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#Header().().Setscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Header#Set().("Content-Type", "application/json")
224 if tt.retryAfter != "" {
225 w.Headerscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#Header().().Setscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Header#Set().("Retry-After", tt.retryAfter)
226 }
227
228 w.WriteHeaderscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#WriteHeader().(tt.statusCode)
229 w.Writescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#Write().([]byte(`{"message":"` + tt.serverMessage + `"}`))
230 }))
231
232 req, err := httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.NewRequestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/NewRequest().("GET", srv.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/Server#URL.+"/test", nil)
233 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, err)
234
235 _, err = c.Doscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Do().(req)
236 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Errorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Error().(t, err)
237
238 _, retryLater := errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.IsRetriableLaterErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/IsRetriableLaterError().(err)
239 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, tt.expectedRetriable, errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.IsRetriableErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/IsRetriableError().(err))
240 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, tt.expectedRetryLater, retryLater)
241
242 srv.Closescip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/Server#Close().()
243 })
244 }
245
246 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.EqualValuesscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/EqualValues().(t, 2, called)
247 }
248
249 func TestRateLimitedWithoutBodyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/TestRateLimitedWithoutBody().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
250 c := NewClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/NewClient().(nil)
251
252 var called uint32
253
254 tests := []struct {
255 name string
256 statusCode int
257 retryAfter string
258 expectedRetriable bool
259 expectedRetryLater bool
260 }{
261 {
262 name: "429 without Retry-After",
263 statusCode: 429,
264 expectedRetriable: true,
265 },
266 {
267 name: "429 with Retry-After",
268 statusCode: 429,
269 retryAfter: "60",
270 expectedRetryLater: true,
271 },
272 }
273
274 for _, tt := range tests {
275 t.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Run().(tt.name, func(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
276 srv := httptestscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/.NewServerscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/NewServer().(httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.HandlerFuncscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/HandlerFunc#(func(w httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.ResponseWriterscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#, r *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#) {
277 if r.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#URL..Stringscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#String().() != "/test" {
278 w.WriteHeaderscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#WriteHeader().(httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.StatusNotFoundscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/StatusNotFound.)
279 return
280 }
281
282 atomicscip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/.AddUint32scip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/AddUint32().(&called, 1)
283 if tt.retryAfter != "" {
284 w.Headerscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#Header().().Setscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Header#Set().("Retry-After", tt.retryAfter)
285 }
286 w.WriteHeaderscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/ResponseWriter#WriteHeader().(tt.statusCode)
287 }))
288
289 req, err := httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.NewRequestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/NewRequest().("GET", srv.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/Server#URL.+"/test", nil)
290 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, err)
291
292 _, err = c.Doscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Do().(req)
293 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Errorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Error().(t, err)
294
295 _, retryLater := errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.IsRetriableLaterErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/IsRetriableLaterError().(err)
296 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, tt.expectedRetriable, errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.IsRetriableErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/IsRetriableError().(err))
297 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, tt.expectedRetryLater, retryLater)
298
299 srv.Closescip-go gomod github.com/golang/go/src go1.25.0 `net/http/httptest`/Server#Close().()
300 })
301 }
302
303 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.EqualValuesscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/EqualValues().(t, 2, called)
304 }