8000 test: typegen output · joeally/postgres-meta@519a85d · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit 519a85d

Browse files
committed
test: typegen output
1 parent 5e4c87f commit 519a85d

File tree

4 files changed

+194
-18
lines changed

4 files changed

+194
-18
lines changed

test/index.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// TODO: Change lib tests to server tests.
2+
// https://github.com/supabase/postgres-meta/issues/397#issuecomment-1285078489
3+
import './lib/query'
4+
import './lib/config'
5+
import './lib/secrets'
6+
import './lib/version'
7+
import './lib/schemas'
8+
import './lib/types'
9+
import './lib/functions'
10+
import './lib/tables'
11+
import './lib/columns'
12+
import './lib/extensions'
13+
import './lib/roles'
14+
import './lib/policies'
15+
import './lib/publications'
16+
import './lib/triggers'
17+
import './lib/views'
18+
import './lib/foreign-tables'
19+
import './server/typegen'

test/lib/index.test.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

test/server/typegen.ts

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
import { app } from './utils'
2+
3+
test('typegen', async () => {
4+
const { body } = await app.inject({ method: 'GET', path: '/generators/typescript' })
5+
// This is expected to be very brittle, as generated types can change a lot
6+
// without being breaking changes. Use `npm run test:update` to make life
7+
// easier.
8+
expect(body).toMatchInlineSnapshot(`
9+
"export type Json =
10+
| string
11+
| number
12+
| boolean
13+
| null
14+
| { [key: string]: Json }
15+
| Json[]
16+
17+
export interface Database {
18+
public: {
19+
Tables: {
20+
category: {
21+
Row: {
22+
id: number
23+
name: string
24+
}
25+
Insert: {
26+
id?: number
27+
name: string
28+
}
29+
Update: {
30+
id?: number
31+
name?: string
32+
}
33+
}
34+
memes: {
35+
Row: {
36+
category: number | null
37+
created_at: string
38+
id: number
39+
metadata: Json | null
40+
name: string
41+
status: Database["public"]["Enums"]["meme_status"] | null
42+
}
43+
Insert: {
44+
category?: number | null
45+
created_at: string
46+
id?: number
47+
metadata?: Json | null
48+
name: string
49+
status?: Database["public"]["Enums"]["meme_status"] | null
50+
}
51+
Update: {
52+
category?: number | null
53+
created_at?: string
54+
id?: number
55+
metadata?: Json | null
56+
name?: string
57+
status?: Database["public"]["Enums"]["meme_status"] | null
58+
}
59+
}
60+
todos: {
61+
Row: {
62+
details: string | null
63+
id: number
64+
"user-id": number
65+
blurb: string | null
66+
}
67+
Insert: {
68+
details?: string | null
69+
id?: number
70+
"user-id": number
71+
}
72+
Update: {
73+
details?: string | null
74+
id?: number
75+
"user-id"?: number
76+
}
77+
}
78+
users: {
79+
Row: {
80+
id: number
81+
name: string | null
82+
status: Database["public"]["Enums"]["user_status"] | null
83+
}
84+
Insert: {
85+
id?: number
86+
name?: string | null
87+
status?: Database["public"]["Enums"]["user_status"] | null
88+
}
89+
Update: {
90+
id?: number
91+
name?: string | null
92+
status?: Database["public"]["Enums"]["user_status"] | null
93+
}
94+
}
95+
users_audit: {
96+
Row: {
97+
created_at: string | null
98+
id: number
99+
previous_value: Json | null
100+
user_id: number | null
101+
}
102+
Insert: {
103+
created_at?: string | null
104+
id?: number
105+
previous_value?: Json | null
106+
user_id?: number | null
107+
}
108+
Update: {
109+
created_at?: string | null
110+
id?: number
111+
previous_value?: Json | null
112+
user_id?: number | null
113+
}
114+
}
115+
}
116+
Views: {
117+
todos_view: {
118+
Row: {
119+
details: string | null
120+
id: number | null
121+
"user-id": number | null
122+
}
123+
Insert: {
124+
details?: string | null
125+
id?: number | null
126+
"user-id"?: number | null
127+
}
128+
Update: {
129+
details?: string | null
130+
id?: number | null
131+
"user-id"?: number | null
132+
}
133+
}
134+
}
135+
Functions: {
136+
blurb: {
137+
Args: {
138+
"": unknown
139+
}
140+
Returns: string
141+
}
142+
postgres_fdw_disconnect: {
143+
Args: {
144+
"": string
145+
}
146+
Returns: boolean
147+
}
148+
postgres_fdw_disconnect_all: {
149+
Args: Record<PropertyKey, never>
150+
Returns: boolean
151+
}
152+
postgres_fdw_get_connections: {
153+
Args: Record<PropertyKey, never>
154+
Returns: Record<string, unknown>[]
155+
}
156+
postgres_fdw_handler: {
157+
Args: Record<PropertyKey, never>
158+
Returns: unknown
159+
}
160+
}
161+
Enums: {
162+
meme_status: "new" | "old" | "retired"
163+
user_status: "ACTIVE" | "INACTIVE"
164+
}
165+
CompositeTypes: {
166+
[_ in never]: never
167+
}
168+
}
169+
}
170+
"
171+
`)
172+
})

test/server/utils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { build as buildApp } from '../../src/server/app'
2+
3+
export const app = buildApp()

0 commit comments

Comments
 (0)
0