File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 55from functools import lru_cache
66from typing import Literal
77
8- from pydantic import PostgresDsn , computed_field
8+ from pydantic import computed_field , field_validator
99from pydantic_settings import BaseSettings , SettingsConfigDict
1010
1111
@@ -31,7 +31,20 @@ class Settings(BaseSettings):
3131 WORKERS : int = 1
3232
3333 # ===== 数据库配置 =====
34- DATABASE_URL : PostgresDsn = "postgresql+asyncpg://postgres:postgres@localhost:5432/querygpt"
34+ DATABASE_URL : str = "postgresql+asyncpg://postgres:postgres@localhost:5432/querygpt"
35+
36+ @field_validator ("DATABASE_URL" )
37+ @classmethod
38+ def validate_database_url (cls , v : str ) -> str :
39+ """验证数据库 URL 格式"""
40+ valid_prefixes = (
41+ "postgresql://" , "postgresql+asyncpg://" ,
42+ "sqlite://" , "sqlite+aiosqlite://" ,
43+ "mysql://" , "mysql+aiomysql://" ,
44+ )
45+ if not any (v .startswith (p ) for p in valid_prefixes ):
46+ raise ValueError (f"DATABASE_URL 必须以以下前缀开头: { valid_prefixes } " )
47+ return v
3548
3649 # ===== Redis 配置 (可选) =====
3750 REDIS_URL : str | None = None
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ describe("Auth Store", () => {
2626
2727 expect ( state . user ) . toBeNull ( ) ;
2828 expect ( state . isAuthenticated ) . toBe ( false ) ;
29- expect ( state . isLoading ) . toBe ( false ) ;
29+ expect ( state . accessToken ) . toBeNull ( ) ;
3030 } ) ;
3131
3232 it ( "should have login function" , async ( ) => {
You can’t perform that action at this time.
0 commit comments