@@ -190,6 +190,7 @@ func TestBadHandler(t *testing.T) {
190
190
t .Errorf ("handlerBad should not be accepted" )
191
191
}
192
192
}
193
+
193
194
func TestBadVerbOn (t * testing.T ) {
194
195
mux := New ()
195
196
verb := "BLUB"
@@ -198,6 +199,7 @@ func TestBadVerbOn(t *testing.T) {
198
199
t .Errorf ("%s should not be accepted" , verb )
199
200
}
200
201
}
202
+
201
203
func TestBadVerbServe (t * testing.T ) {
202
204
var (
203
205
method = "BLUB"
@@ -217,6 +219,7 @@ func TestBadVerbServe(t *testing.T) {
217
219
t .Errorf ("%s %s got %d want %d" , method , path , res .Code , want )
218
220
}
219
221
}
222
+
220
223
func TestDuplicateFailure (t * testing.T ) {
221
224
var (
222
225
handler HandlerFunc
@@ -235,6 +238,7 @@ func TestDuplicateFailure(t *testing.T) {
235
238
}
236
239
}
237
240
}
241
+
238
242
func TestDuplicateFailureRoot (t * testing.T ) {
239
243
var (
240
244
handler HandlerFunc
@@ -253,6 +257,7 @@ func TestDuplicateFailureRoot(t *testing.T) {
253
257
}
254
258
}
255
259
}
260
+
256
261
func TestMiddleware (t * testing.T ) {
257
262
var (
258
263
middlewares int = 4
@@ -328,6 +333,7 @@ func TestMiddleware(t *testing.T) {
328
333
run (verb )
329
334
}
330
335
}
336
+
331
337
func TestMiddlewareRejectionA (t * testing.T ) {
332
338
mux := New ()
333
339
one := func (http.ResponseWriter , * http.Request , * Context ) {}
@@ -337,6 +343,7 @@ func TestMiddlewareRejectionA(t *testing.T) {
337
343
t .Errorf ("middleware with wrong signature was accepted" )
338
344
}
339
345
}
346
+
340
347
func TestMiddlewareRejectionB (t * testing.T ) {
341
348
mux := New ()
342
349
one := http .HandlerFunc (func (http.ResponseWriter , * http.Request ) {})
@@ -348,6 +355,7 @@ func TestMiddlewareRejectionB(t *testing.T) {
348
355
t .Errorf ("middleware with wrong signature was accepted" )
349
356
}
350
357
}
358
+
351
359
func TestMiddlewareRejectionC (t * testing.T ) {
352
360
mux := New ()
353
361
one := http .HandlerFunc (func (http.ResponseWriter , * http.Request ) {})
@@ -356,6 +364,7 @@ func TestMiddlewareRejectionC(t *testing.T) {
356
364
t .Errorf ("middleware with wrong signature was accepted" )
357
365
}
358
366
}
367
+
359
368
func TestMiddlewareRejectionD (t * testing.T ) {
360
369
mux := New ()
361
370
one := http .HandlerFunc (func (http.ResponseWriter , * http.Request ) {})
@@ -364,6 +373,7 @@ func TestMiddlewareRejectionD(t *testing.T) {
364
373
t .Errorf ("middleware with wrong signature was accepted" )
365
374
}
366
375
}
376
+
367
377
func TestMiddlewareRejectionE (t * testing.T ) {
368
378
mux := New ()
369
379
var (
@@ -389,6 +399,7 @@ func TestMiddlewareRejectionE(t *testing.T) {
389
399
t .Errorf ("nil middleware was accepted" )
390
400
}
391
401
}
402
+
392
403
func TestNoHandlers (t * testing.T ) {
393
404
var (
394
405
mux * Mux = New ()
@@ -406,6 +417,7 @@ func TestNoHandlers(t *testing.T) {
406
417
}
407
418
}
408
419
}
420
+
409
421
func TestNotFoundCustom (t * testing.T ) {
410
422
var (
411
423
method string = "GET"
@@ -448,6 +460,7 @@ func TestNotFoundCustom(t *testing.T) {
448
460
method , pathLost , patternLost , res .Code , wantLost )
449
461
}
450
462
}
463
+
451
464
func TestNotFoundNoParams (t * testing.T ) {
452
465
var (
453
466
path = "/foo/bar"
@@ -472,6 +485,7 @@ func TestNotFoundNoParams(t *testing.T) {
472
485
verb , path , pattern , want )(t )
473
486
}
474
487
}
488
+
475
489
func TestNotFoundParams (t * testing.T ) {
476
490
var (
477
491
path = "/foo/BAR/baz"
@@ -496,6 +510,7 @@ func TestNotFoundParams(t *testing.T) {
496
510
verb , path , pattern , want )(t )
497
511
}
498
512
}
513
+
499
514
func TestNotFoundRoot (t * testing.T ) {
500
515
var (
501
516
method string = "GET"
@@ -512,6 +527,7 @@ func TestNotFoundRoot(t *testing.T) {
512
527
t .Errorf ("%s %s got %d want %d" , method , path , res .Code , want )
513
528
}
514
529
}
530
+
515
531
func TestNotFoundWildA (t * testing.T ) {
516
532
var (
517
533
path = "/foo"
@@ -536,6 +552,7 @@ func TestNotFoundWildA(t *testing.T) {
536
552
verb , path , pattern , want )(t )
537
553
}
538
554
}
555
+
539
556
func TestNotFoundWildB (t * testing.T ) {
540
557
var (
541
558
method string = "GET"
@@ -557,6 +574,7 @@ func TestNotFoundWildB(t *testing.T) {
557
574
t .Errorf ("%s %s got %d want %d" , method , path , res .Code , want )
558
575
}
559
576
}
577
+
560
578
func TestOKMultiRuleParams (t * testing.T ) {
561
579
var (
562
580
method string = "GET"
@@ -578,6 +596,7 @@ func TestOKMultiRuleParams(t *testing.T) {
578
596
t .Errorf ("%s %s got %d want %d" , method , path , res .Code , want )
579
597
}
580
598
}
599
+
581
600
func TestOKNoParams (t * testing.T ) {
582
601
var (
583
602
path = "/foo/bar"
@@ -599,6 +618,7 @@ func TestOKNoParams(t *testing.T) {
599
618
verb , path , pattern , want )(t )
600
619
}
601
620
}
621
+
602
622
func TestOKParams (t * testing.T ) {
603
623
var (
604
624
path = "/foo/BAR/baz/QUX"
@@ -621,6 +641,7 @@ func TestOKParams(t *testing.T) {
621
641
verb , path , pattern , want )(t )
622
642
}
623
643
}
644
+
624
645
func TestOKParamsTrailingSlash (t * testing.T ) {
625
646
var (
626
647
path = "/foo/BAR/baz/QUX/"
@@ -643,6 +664,7 @@ func TestOKParamsTrailingSlash(t *testing.T) {
643
664
verb , path , pattern , want )(t )
644
665
}
645
666
}
667
+
646
668
func TestOKRoot (t * testing.T ) {
647
669
var (
648
670
path = "/"
@@ -664,6 +686,7 @@ func TestOKRoot(t *testing.T) {
664
686
verb , path , pattern , want )(t )
665
687
}
666
688
}
689
+
667
690
func TestOKWildRoot (t * testing.T ) {
668
691
var (
669
692
path = "/"
@@ -685,6 +708,7 @@ func TestOKWildRoot(t *testing.T) {
685
708
verb , path , pattern , want )(t )
686
709
}
687
710
}
711
+
688
712
func TestSanitizePatternPrefixSuffix (t * testing.T ) {
689
713
var (
690
714
method = "GET"
@@ -707,6 +731,7 @@ func TestSanitizePatternPrefixSuffix(t *testing.T) {
707
731
t .Errorf ("%s %s (%s) got %s want %s" , method , path , pattern , body , want )
708
732
}
709
733
}
734
+
710
735
func TestSanitizePatternDoubleSlash (t * testing.T ) {
711
736
var (
712
737
method = "GET"
@@ -729,6 +754,7 @@ func TestSanitizePatternDoubleSlash(t *testing.T) {
729
754
t .Errorf ("%s %s (%s) got %s want %s" , method , path , pattern , body , want )
730
755
}
731
756
}
757
+
732
758
func TestUnreachableA (t * testing.T ) {
733
759
mux := New ()
734
760
one := func (http.ResponseWriter , * http.Request , * Context ) {}
@@ -739,6 +765,7 @@ func TestUnreachableA(t *testing.T) {
739
765
t .Errorf ("unreachable A" )
740
766
}
741
767
}
768
+
742
769
func TestUnreachableB (t * testing.T ) {
743
770
mux := New ()
744
771
one := func (http.ResponseWriter , * http.Request , * Context ) {}
@@ -749,6 +776,7 @@ func TestUnreachableB(t *testing.T) {
749
776
t .Errorf ("unreachable B" )
750
777
}
751
778
}
779
+
752
780
func TestWildcardCompeting (t * testing.T ) {
753
781
var (
754
782
method string = "GET"
@@ -797,6 +825,7 @@ func TestWildcardCompeting(t *testing.T) {
797
825
method , pathThree , patternThree , body , wantThree )
798
826
}
799
827
}
828
+
800
829
func TestWildcardMethod (t * testing.T ) {
801
830
var (
802
831
mux = New ()
@@ -821,6 +850,7 @@ func TestWildcardMethod(t *testing.T) {
821
850
}
822
851
}
823
852
}
853
+
824
854
func TestWildcardMethodWarning (t * testing.T ) {
825
855
var (
826
856
mux = New ()
@@ -835,6 +865,7 @@ func TestWildcardMethodWarning(t *testing.T) {
835
865
t .Errorf ("* %s should have registered, but with an error" , pattern )
836
866
}
837
867
}
868
+
838
869
func TestWildcardNotLast (t * testing.T ) {
839
870
var (
840
871
mux = New ()
@@ -848,6 +879,7 @@ func TestWildcardNotLast(t *testing.T) {
848
879
pattern )
849
880
}
850
881
}
882
+
851
883
func TestWildcardParams (t * testing.T ) {
852
884
var (
853
885
method = "GET"
@@ -870,6 +902,7 @@ func TestWildcardParams(t *testing.T) {
870
902
t .Errorf ("%s %s (%s) got %s want %s" , method , path , pattern , body , want )
871
903
}
872
904
}
905
+
873
906
func TestAlways (t * testing.T ) {
874
907
var (
875
908
mux * Mux = New ()
@@ -934,6 +967,7 @@ func TestAlwaysBeforeNotFound(t *testing.T) {
934
967
res = httptest .NewRecorder ()
935
968
mux .ServeHTTP (res , req )
936
969
}
970
+
937
971
func TestAlwaysRejection (t * testing.T ) {
938
972
var (
939
973
mux * Mux = New ()
@@ -943,15 +977,15 @@ func TestAlwaysRejection(t *testing.T) {
943
977
four func (http.ResponseWriter , * http.Request , * Context )
944
978
)
945
979
if err := mux .Always (one ); err == nil {
946
- t .Errorf ("Always requires non-nil HandlerFunc or its signature " )
980
+ t .Errorf ("Always requires non-nil handler " )
947
981
}
948
982
if err := mux .Always (two ); err == nil {
949
- t .Errorf ("Always requires non-nil HandlerFunc or its signature " )
983
+ t .Errorf ("Always requires non-nil handler " )
950
984
}
951
985
if err := mux .Always (three ); err == nil {
952
- t .Errorf ("Always requires non-nil HandlerFunc or its signature " )
986
+ t .Errorf ("Always requires non-nil handler " )
953
987
}
954
988
if err := mux .Always (four ); err == nil {
955
- t .Errorf ("Always requires non-nil HandlerFunc or its signature " )
989
+ t .Errorf ("Always requires non-nil handler " )
956
990
}
957
991
}
0 commit comments