--- PATCH /api/auth/me (Item #8) ---
(t *testing.T)
| 272 | // --- PATCH /api/auth/me (Item #8) --- |
| 273 | |
| 274 | func 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 | |
| 298 | func TestHandleUpdateMe_Unauthenticated(t *testing.T) { |
| 299 | ua, _, _ := setupUserAuth(t) |
nothing calls this directly
no test coverage detected