11package pulse
22
33import (
4- "fmt"
54 "testing"
65 "time"
76)
@@ -22,70 +21,19 @@ func TestRouterHandler(t *testing.T) {
2221 ctx .String ("hello" )
2322 return nil
2423 })
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-
7624}
7725
78- func TestContext_SetHeader (t * testing.T ) {
26+ func TestRouter_find (t * testing.T ) {
7927 router := NewRouter ()
8028
8129 app .Router = router
8230
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" )
8633 return nil
8734 })
8835
36+ router .find ("GET" , "/users/1" )
8937}
9038
9139func TestRouter_Static (t * testing.T ) {
@@ -99,5 +47,4 @@ func TestRouter_Static(t *testing.T) {
9947 IndexName : "index.html" ,
10048 CacheDuration : 24 * time .Hour ,
10149 })
102-
10350}
0 commit comments