(t *testing.T)
| 123 | } |
| 124 | |
| 125 | func TestAddRoute_ValidMethod(t *testing.T) { |
| 126 | server := New() |
| 127 | server.AddRoute("GET", "/test", func(c *Ctx) error { |
| 128 | return c.SendString("ok") |
| 129 | }) |
| 130 | |
| 131 | req := httptest.NewRequest("GET", "/test", nil) |
| 132 | rr := httptest.NewRecorder() |
| 133 | server.ServeHTTP(rr, req) |
| 134 | |
| 135 | if rr.Code != http.StatusOK { |
| 136 | t.Errorf("expected 200, got %d", rr.Code) |
| 137 | } |
| 138 | if len(server.routes) == 0 { |
| 139 | t.Error("expected at least one route to be stored") |
| 140 | } |
| 141 | route := server.routes[0] |
| 142 | if route.Path != "/test" { |
| 143 | t.Errorf("expected route path '/test', got '%s'", route.Path) |
| 144 | } |
| 145 | if route.Method != "GET" { |
| 146 | t.Errorf("expected route method 'GET', got '%s'", route.Method) |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | func TestGet(t *testing.T) { |
| 151 | server := New() |
nothing calls this directly
no test coverage detected