MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / TestHandleUpdateMe_HappyPath

Function TestHandleUpdateMe_HappyPath

internal/auth/auth_test.go:274–296  ·  view source on GitHub ↗

--- PATCH /api/auth/me (Item #8) ---

(t *testing.T)

Source from the content-addressed store, hash-verified

272// --- PATCH /api/auth/me (Item #8) ---
273
274func TestHandleUpdateMe_HappyPath(t *testing.T) {
275 ua, store, token := setupUserAuth(t)
276 ctx := context.Background()
277
278 req := authedJSON("PATCH", "/api/auth/me", token, `{"name":"Jamie"}`)
279 w := httptest.NewRecorder()
280 ua.HandleUpdateMe(w, req)
281
282 if w.Code != http.StatusOK {
283 t.Fatalf("status = %d, want 200; body=%s", w.Code, w.Body.String())
284 }
285 var got identity.User
286 json.NewDecoder(w.Body).Decode(&got)
287 if got.Name != "Jamie" {
288 t.Errorf("returned Name = %q, want Jamie", got.Name)
289 }
290
291 // Round-trip: a follow-up GetUserByID sees the persisted name.
292 persisted, _ := store.GetUserByID(ctx, got.ID)
293 if persisted.Name != "Jamie" {
294 t.Errorf("persisted Name = %q, want Jamie", persisted.Name)
295 }
296}
297
298func TestHandleUpdateMe_Unauthenticated(t *testing.T) {
299 ua, _, _ := setupUserAuth(t)

Callers

nothing calls this directly

Calls 5

setupUserAuthFunction · 0.85
HandleUpdateMeMethod · 0.80
GetUserByIDMethod · 0.80
authedJSONFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected