MCPcopy Create free account
hub / github.com/BryanMwangi/pine / TestAddRoute_ValidMethod

Function TestAddRoute_ValidMethod

pine_test.go:125–148  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

123}
124
125func 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
150func TestGet(t *testing.T) {
151 server := New()

Callers

nothing calls this directly

Calls 5

SendStringMethod · 0.80
ServeHTTPMethod · 0.80
ErrorMethod · 0.80
NewFunction · 0.70
AddRouteMethod · 0.45

Tested by

no test coverage detected