@@ -126,48 +126,8 @@ func TestNotFound(t *testing.T) {
126126 }
127127}
128128
129- // go test -v -cover -count=1 -test.cpu=1 -run=^TestRequireLogin$
130- func TestRequireLogin (t * testing.T ) {
131- testCases := []struct {
132- message string
133- args []any
134- wantCode int32
135- wantMessage string
136- }{
137- {
138- message : "xxx" ,
139- args : nil ,
140- wantCode : codeRequireLogin ,
141- wantMessage : "xxx" ,
142- },
143- {
144- message : "xxx %d%.2f" ,
145- args : nil ,
146- wantCode : codeRequireLogin ,
147- wantMessage : "xxx %d%.2f" ,
148- },
149- {
150- message : "xxx %d%s%+v" ,
151- args : []any {1 , "." , true },
152- wantCode : codeRequireLogin ,
153- wantMessage : "xxx 1.true" ,
154- },
155- }
156-
157- for _ , testCase := range testCases {
158- err := RequireLogin (testCase .message , testCase .args ... )
159- if err .Code () != testCase .wantCode {
160- t .Errorf ("err.Code() %d != testCase.wantCode %d" , err .Code (), testCase .wantCode )
161- }
162-
163- if err .Message () != testCase .wantMessage {
164- t .Errorf ("err.Message() %s != testCase.wantMessage %s" , err .Message (), testCase .wantMessage )
165- }
166- }
167- }
168-
169- // go test -v -cover -count=1 -test.cpu=1 -run=^TestMatchBadRequest$
170- func TestMatchBadRequest (t * testing.T ) {
129+ // go test -v -cover -count=1 -test.cpu=1 -run=^TestIsBadRequest$
130+ func TestIsBadRequest (t * testing.T ) {
171131 testCases := []struct {
172132 message string
173133 }{
@@ -178,14 +138,14 @@ func TestMatchBadRequest(t *testing.T) {
178138
179139 for _ , testCase := range testCases {
180140 err := BadRequest (testCase .message )
181- if ! MatchBadRequest (err ) {
182- t .Errorf ("err %+v not match code %d" , err , err .Code ())
141+ if ! IsBadRequest (err ) {
142+ t .Errorf ("err %+v not code %d" , err , err .Code ())
183143 }
184144 }
185145}
186146
187- // go test -v -cover -count=1 -test.cpu=1 -run=^TestMatchForbidden $
188- func TestMatchForbidden (t * testing.T ) {
147+ // go test -v -cover -count=1 -test.cpu=1 -run=^TestIsForbidden $
148+ func TestIsForbidden (t * testing.T ) {
189149 testCases := []struct {
190150 message string
191151 }{
@@ -196,14 +156,14 @@ func TestMatchForbidden(t *testing.T) {
196156
197157 for _ , testCase := range testCases {
198158 err := Forbidden (testCase .message )
199- if ! MatchForbidden (err ) {
200- t .Errorf ("err %+v not match code %d" , err , err .Code ())
159+ if ! IsForbidden (err ) {
160+ t .Errorf ("err %+v not code %d" , err , err .Code ())
201161 }
202162 }
203163}
204164
205- // go test -v -cover -count=1 -test.cpu=1 -run=^TestMatchNotFound $
206- func TestMatchNotFound (t * testing.T ) {
165+ // go test -v -cover -count=1 -test.cpu=1 -run=^TestIsNotFound $
166+ func TestIsNotFound (t * testing.T ) {
207167 testCases := []struct {
208168 message string
209169 }{
@@ -214,26 +174,8 @@ func TestMatchNotFound(t *testing.T) {
214174
215175 for _ , testCase := range testCases {
216176 err := NotFound (testCase .message )
217- if ! MatchNotFound (err ) {
218- t .Errorf ("err %+v not match code %d" , err , err .Code ())
219- }
220- }
221- }
222-
223- // go test -v -cover -count=1 -test.cpu=1 -run=^TestMatchRequireLogin$
224- func TestMatchRequireLogin (t * testing.T ) {
225- testCases := []struct {
226- message string
227- }{
228- {
229- message : "xxx" ,
230- },
231- }
232-
233- for _ , testCase := range testCases {
234- err := RequireLogin (testCase .message )
235- if ! MatchRequireLogin (err ) {
236- t .Errorf ("err %+v not match code %d" , err , err .Code ())
177+ if ! IsNotFound (err ) {
178+ t .Errorf ("err %+v not code %d" , err , err .Code ())
237179 }
238180 }
239181}
0 commit comments