@@ -534,3 +534,61 @@ func TestContext_SetRequestHeader(t *testing.T) {
534
534
ctx .SetRequestHeader ("key" , "value" )
535
535
assert .Equal (t , "value" , ctx .GetRequestHeader ("key" ))
536
536
}
537
+
538
+ func TestContext_Path (t * testing.T ) {
539
+ ctx := newContext (New ())
540
+
541
+ req := httptest .NewRequest (http .MethodGet , "/path" , nil )
542
+ req .URL .Path = "/path"
543
+ req .URL .RawPath = ""
544
+
545
+ ctx .reset (req , nil )
546
+
547
+ assert .Equal (t , "/path" , ctx .Path ())
548
+
549
+ req .URL .RawPath = "/path2"
550
+ assert .Equal (t , "/path2" , ctx .Path ())
551
+ }
552
+
553
+ func TestContext_Method (t * testing.T ) {
554
+ ctx := newContext (New ())
555
+
556
+ req := httptest .NewRequest (http .MethodDelete , "/path" , nil )
557
+
558
+ ctx .reset (req , nil )
559
+
560
+ assert .Equal (t , http .MethodDelete , ctx .Method ())
561
+ }
562
+
563
+ func TestContext_Clone (t * testing.T ) {
564
+ ctx := newContext (New ())
565
+
566
+ req := httptest .NewRequest (http .MethodDelete , "/path" , nil )
567
+ res := httptest .NewRecorder ()
568
+
569
+ ctx .reset (req , res )
570
+
571
+ ctx .Set ("key" , "value1" )
572
+ ctx .params ["key" ] = "value2"
573
+
574
+ clonedCtx := ctx .Clone ()
575
+
576
+ ctx .Set ("key" , "value" )
577
+ ctx .params ["key" ] = "value"
578
+
579
+ assert .NotEqual (t , ctx , clonedCtx )
580
+ assert .NotEqual (t , ctx .request , clonedCtx .request )
581
+ assert .NotEqual (t , ctx .response , clonedCtx .response )
582
+ assert .Equal (t , "value1" , clonedCtx .storage ["key" ])
583
+ assert .Equal (t , "value2" , clonedCtx .Param ("key" ))
584
+ assert .Equal (t , ctx .kid , clonedCtx .kid )
585
+ assert .NotNil (t , ctx .response .(* response ).ResponseWriter )
586
+
587
+ assert .Panics (t , func () {
588
+ clonedCtx .Byte (http .StatusAccepted , []byte ("test" ))
589
+ })
590
+
591
+ assert .NotPanics (t , func () {
592
+ clonedCtx .Response ().Status ()
593
+ })
594
+ }
0 commit comments