@@ -2,6 +2,7 @@ import { existsSync, mkdirSync, rmSync, writeFileSync } from 'node:fs'
22import { join } from 'node:path'
33import { getAuthTables } from 'better-auth/db'
44import { afterAll , beforeAll , describe , expect , it } from 'vitest'
5+ import { buildSchemaExportCode } from '../src/module/templates'
56import { defineClientAuth , defineServerAuth } from '../src/runtime/config'
67import { generateDrizzleSchema , loadUserAuthConfig } from '../src/schema-generator'
78
@@ -76,6 +77,17 @@ describe('generateDrizzleSchema', () => {
7677 } )
7778} )
7879
80+ describe ( 'buildSchemaExportCode' , ( ) => {
81+ it ( 'exports stable undefined auth table aliases without hub db' , ( ) => {
82+ const code = buildSchemaExportCode ( false , 'sqlite' )
83+ expect ( code ) . toContain ( 'export const user = undefined' )
84+ expect ( code ) . toContain ( 'export const session = undefined' )
85+ expect ( code ) . toContain ( 'export const account = undefined' )
86+ expect ( code ) . toContain ( 'export const verification = undefined' )
87+ expect ( code ) . toContain ( 'export const schema = undefined' )
88+ } )
89+ } )
90+
7991describe ( 'getAuthTables with secondaryStorage' , ( ) => {
8092 it ( 'excludes session table when secondaryStorage is provided' , ( ) => {
8193 const mockStorage = { get : async ( ) => null , set : async ( ) => { } , delete : async ( ) => { } }
0 commit comments