refactor(routing): 暴露 system_locked_domains + 服务端 follow-up 清理(FK/Validate/dedup/exclude单源/共用Store/Builtin保留)

This commit is contained in:
wangjia
2026-07-29 06:38:52 +08:00
parent 52912268d0
commit 3159dd75c1
11 changed files with 285 additions and 36 deletions
@@ -32,6 +32,27 @@ func seedU(t *testing.T, db *sql.DB, id int64, uuid string) {
}
}
// TestSQLiteRoutingStoreGetNoProfileRow isolates the "queried the DB, found
// no row" path from TestSQLiteRoutingStoreUpsertGet's combined
// empty→upsert→overwrite flow: a store backed by a real (non-nil) *sql.DB,
// with the user seeded but no routing_profiles row for them, must return
// (nil, nil) — not an error — via the sql.ErrNoRows branch in Store.Get.
func TestSQLiteRoutingStoreGetNoProfileRow(t *testing.T) {
db := openDB(t)
seedU(t, db, 2, "u2")
st := NewStore(db)
if st == nil {
t.Fatal("NewStore returned nil")
}
got, err := st.Get(context.Background(), 2)
if err != nil {
t.Fatalf("want nil error for no-rows, got %v", err)
}
if got != nil {
t.Fatalf("want nil profile for seeded user with no profile row, got %+v", got)
}
}
func TestSQLiteRoutingStoreUpsertGet(t *testing.T) {
db := openDB(t) // 内存库 + MigrateUp(sqlite)
seedU(t, db, 1, "u1")