From 5c959ab43fc86115b9ce9c069655b8ff5c0abd77 Mon Sep 17 00:00:00 2001 From: z1551778201-ctrl Date: Wed, 13 May 2026 01:21:01 +0200 Subject: [PATCH] test: cover hyperdrive source types Signed-off-by: z1551778201-ctrl --- src/types.test.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/types.test.ts b/src/types.test.ts index 620da15..815ab16 100644 --- a/src/types.test.ts +++ b/src/types.test.ts @@ -5,7 +5,9 @@ import { CloudflareD1Source, StarbaseDBSource, TursoDBSource, + HyperdriveSource, ExternalDatabaseSource, + DataSource, RegionLocationHint, } from './types' @@ -65,6 +67,19 @@ describe('Database Source Type Tests', () => { expectTypeOf(tursoSource).toMatchTypeOf() }) + it('should match the expected HyperdriveSource structure', () => { + const hyperdriveSource: HyperdriveSource = { + dialect: 'postgresql', + connectionString: 'postgres://user:pass@example.com/db', + defaultSchema: 'public', + } + + expect(hyperdriveSource.dialect).toBe('postgresql') + expect(hyperdriveSource.connectionString).toContain('example.com') + expect(hyperdriveSource.defaultSchema).toBe('public') + expectTypeOf(hyperdriveSource).toMatchTypeOf() + }) + it('should allow all ExternalDatabaseSource types', () => { const externalSource: ExternalDatabaseSource = { dialect: 'postgresql', @@ -76,6 +91,25 @@ describe('Database Source Type Tests', () => { } expectTypeOf(externalSource).toMatchTypeOf() }) + + it('should allow DataSource metadata for hyperdrive connections', () => { + const dataSource = { + source: 'hyperdrive', + external: { + dialect: 'postgresql', + connectionString: 'postgres://user:pass@example.com/db', + }, + cache: true, + cacheTTL: 60, + context: { tenant: 'test' }, + } as unknown as DataSource + + expect(dataSource.source).toBe('hyperdrive') + expect(dataSource.external?.dialect).toBe('postgresql') + expect(dataSource.cache).toBe(true) + expect(dataSource.cacheTTL).toBe(60) + expect(dataSource.context).toEqual({ tenant: 'test' }) + }) }) describe('RegionLocationHint Enum Tests', () => {