(t *testing.T)
| 494 | } |
| 495 | |
| 496 | func TestDeleteRemovesSession(t *testing.T) { |
| 497 | gin.SetMode(gin.TestMode) |
| 498 | srv := newTestServer(nil) |
| 499 | |
| 500 | currentSession := srv.createSession(1) |
| 501 | r := gin.New() |
| 502 | r.DELETE("/mcp", func(c *gin.Context) { |
| 503 | common.GinAppendValues(c, conf.UserKey, &model.User{ID: 1, Role: model.ADMIN}) |
| 504 | srv.handleDelete(c) |
| 505 | }) |
| 506 | |
| 507 | req := httptest.NewRequest(http.MethodDelete, "http://example.com/mcp", nil) |
| 508 | req.Header.Set("Origin", "http://example.com") |
| 509 | req.Header.Set(SessionHeader, currentSession.id) |
| 510 | |
| 511 | w := httptest.NewRecorder() |
| 512 | r.ServeHTTP(w, req) |
| 513 | |
| 514 | if w.Code != http.StatusNoContent { |
| 515 | t.Fatalf("unexpected status: got %d want %d", w.Code, http.StatusNoContent) |
| 516 | } |
| 517 | if _, ok := srv.getSession(currentSession.id); ok { |
| 518 | t.Fatal("expected session to be deleted") |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | func TestGetReturnsMethodNotAllowed(t *testing.T) { |
| 523 | gin.SetMode(gin.TestMode) |
nothing calls this directly
no test coverage detected