MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / TestDeleteRemovesSession

Function TestDeleteRemovesSession

server/mcp/handler_test.go:496–520  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

494}
495
496func 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
522func TestGetReturnsMethodNotAllowed(t *testing.T) {
523 gin.SetMode(gin.TestMode)

Callers

nothing calls this directly

Calls 7

GinAppendValuesFunction · 0.92
newTestServerFunction · 0.85
ServeHTTPMethod · 0.80
getSessionMethod · 0.80
createSessionMethod · 0.45
handleDeleteMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected