@@ -155,13 +155,34 @@ describe('/tables', async () => {
155
155
assert . equal ( relationships . length > 0 , true )
156
156
assert . equal ( true , relationship . target_table_id == 'public.users' )
157
157
} )
158
-
159
158
it ( 'GET with system tables' , async ( ) => {
160
159
const res = await axios . get ( `${ URL } /tables?includeSystemSchemas=true` )
161
160
const included = res . data . find ( ( x ) => x . table_id == 'pg_catalog.pg_type' )
162
161
assert . equal ( res . status , STATUS . SUCCESS )
163
162
assert . equal ( true , ! ! included )
164
163
} )
164
+ it ( 'POST' , async ( ) => {
165
+ await axios . post ( `${ URL } /tables` , {
166
+ schema : 'public' ,
167
+ name : 'test' ,
168
+ columns : [
169
+ { name : 'id' , is_identity : true , is_nullable : false , data_type : 'bigint' } ,
170
+ { name : 'data' , data_type : 'text' } ,
171
+ ] ,
172
+ primary_keys : [ 'id' ] ,
173
+ } )
174
+ const { data : tables } = await axios . get ( `${ URL } /tables` )
175
+ const test = tables . find ( ( table ) => table . table_id === 'public.test' )
176
+ const id = test . columns . find ( ( column ) => column . name === 'id' )
177
+ const data = test . columns . find ( ( column ) => column . name === 'data' )
178
+ assert . equal ( id . is_identity , true )
179
+ assert . equal ( id . is_nullable , false )
180
+ assert . equal ( id . data_type , 'bigint' )
181
+ assert . equal ( data . is_identity , false )
182
+ assert . equal ( data . is_nullable , true )
183
+ assert . equal ( data . data_type , 'text' )
184
+ await axios . post ( `${ URL } /query` , { query : 'DROP TABLE public.test' } )
185
+ } )
165
186
} )
166
187
describe ( '/extensions' , ( ) => {
167
188
it ( 'GET' , async ( ) => {
@@ -183,4 +204,24 @@ describe('/roles', () => {
183
204
assert . equal ( hasSystemSchema , false )
184
205
assert . equal ( hasPublicSchema , true )
185
206
} )
207
+ // it('POST', async () => {
208
+ // await axios.post(`${URL}/roles`, {
209
+ // name: 'test',
210
+ // is_super_user: true,
211
+ // has_create_db_privileges: true,
212
+ // has_replication_privileges: true,
213
+ // can_bypass_rls: true,
214
+ // connections: 100,
215
+ // valid_until: '2020-01-01',
216
+ // })
217
+ // const { data: roles } = await axios.get(`${URL}/roles`)
218
+ // const test = roles.find((role) => role.name === 'test')
219
+ // assert.equal(test.is_super_user, true)
220
+ // assert.equal(test.has_create_db_privileges, true)
221
+ // assert.equal(test.has_replication_privileges, true)
222
+ // assert.equal(test.can_bypass_rls, true)
223
+ // assert.equal(test.connections, 100)
224
+ // assert.equal(test.valid_until, '2020-01-01')
225
+ // await axios.post(`${URL}/roles`, { query: 'DROP ROLE test' })
226
+ // })
186
227
} )
0 commit comments