1
1
package pulse
2
2
3
3
import (
4
- "fmt"
5
4
"testing"
6
5
"time"
7
6
)
@@ -22,70 +21,19 @@ func TestRouterHandler(t *testing.T) {
22
21
ctx .String ("hello" )
23
22
return nil
24
23
})
25
-
26
- }
27
-
28
- func TestCORSMiddleware (t * testing.T ) {
29
- router := NewRouter ()
30
-
31
- app .Router = router
32
-
33
- router .Get ("/" , func (ctx * Context ) error {
34
- return nil
35
- })
36
-
37
- router .Use ("GET" , CORSMiddleware ())
38
-
39
- }
40
-
41
- func TestContext_SetCookie (t * testing.T ) {
42
- router := NewRouter ()
43
-
44
- app .Router = router
45
-
46
- router .Get ("/" , func (ctx * Context ) error {
47
- cookie := Cookie {
48
- Name : "Test Cookie 1" ,
49
- Value : "Test Cookie 1" ,
50
- Path : "/" ,
51
- Domain : "localhost" ,
52
- MaxAge : 0 ,
53
- Expires : time .Now ().Add (24 * time .Hour ),
54
- Secure : false ,
55
- HTTPOnly : false ,
56
- SameSite : "Lax" ,
57
- SessionOnly : false ,
58
- }
59
- ctx .SetCookie (& cookie )
60
- return nil
61
- })
62
-
63
- }
64
-
65
- func TestContext_GetCookie (t * testing.T ) {
66
- router := NewRouter ()
67
-
68
- app .Router = router
69
-
70
- router .Get ("/" , func (ctx * Context ) error {
71
- cookie := ctx .GetCookie ("test" )
72
- ctx .String (cookie )
73
- return nil
74
- })
75
-
76
24
}
77
25
78
- func TestContext_SetHeader (t * testing.T ) {
26
+ func TestRouter_find (t * testing.T ) {
79
27
router := NewRouter ()
80
28
81
29
app .Router = router
82
30
83
- router .Get ("/" , func (ctx * Context ) error {
84
- ctx .SetHeader ("Test Header" , "test header value" )
85
- fmt .Println (ctx .GetHeader ("test" ))
31
+ router .Get ("/users/*" , func (ctx * Context ) error {
32
+ ctx .String ("hello" )
86
33
return nil
87
34
})
88
35
36
+ router .find ("GET" , "/users/1" )
89
37
}
90
38
91
39
func TestRouter_Static (t * testing.T ) {
@@ -99,5 +47,4 @@ func TestRouter_Static(t *testing.T) {
99
47
IndexName : "index.html" ,
100
48
CacheDuration : 24 * time .Hour ,
101
49
})
102
-
103
50
}
0 commit comments