@@ -155,13 +155,34 @@ describe('/tables', async () => {
155155 assert . equal ( relationships . length > 0 , true )
156156 assert . equal ( true , relationship . target_table_id == 'public.users' )
157157 } )
158-
159158 it ( 'GET with system tables' , async ( ) => {
160159 const res = await axios . get ( `${ URL } /tables?includeSystemSchemas=true` )
161160 const included = res . data . find ( ( x ) => x . table_id == 'pg_catalog.pg_type' )
162161 assert . equal ( res . status , STATUS . SUCCESS )
163162 assert . equal ( true , ! ! included )
164163 } )
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+ } )
165186} )
166187describe ( '/extensions' , ( ) => {
167188 it ( 'GET' , async ( ) => {
@@ -183,4 +204,24 @@ describe('/roles', () => {
183204 assert . equal ( hasSystemSchema , false )
184205 assert . equal ( hasPublicSchema , true )
185206 } )
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+ // })
186227} )
0 commit comments