(t *testing.T)
| 238 | } |
| 239 | |
| 240 | func TestGetUserByAPIKey(t *testing.T) { |
| 241 | pool := testutil.TestDB(t) |
| 242 | store := identity.NewStore(pool) |
| 243 | ctx := context.Background() |
| 244 | |
| 245 | user, _ := store.CreateOrGetUser(ctx, "apikey-lookup@example.com", "Owner", "google-apikey-lookup") |
| 246 | key, _ := store.CreateAPIKey(ctx, user.ID, "lookup-key", nil) |
| 247 | |
| 248 | got, err := store.GetUserByAPIKey(ctx, key.PlaintextKey) |
| 249 | if err != nil { |
| 250 | t.Fatalf("GetUserByAPIKey: %v", err) |
| 251 | } |
| 252 | if got.ID != user.ID { |
| 253 | t.Errorf("ID = %q, want %q", got.ID, user.ID) |
| 254 | } |
| 255 | if got.Email != "apikey-lookup@example.com" { |
| 256 | t.Errorf("Email = %q", got.Email) |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | // TestAPIKey_ListReturnsLastUsedAtAndExpiresAt asserts the columns |
| 261 | // added/exposed by migration 011: last_used_at is populated by |
nothing calls this directly
no test coverage detected