1
1
import { VulcanBuilder , IBuildOptions } from '@vulcan-sql/build' ;
2
2
import { VulcanServer , ServeConfig , APIProviderType } from '@vulcan-sql/serve' ;
3
3
import * as path from 'path' ;
4
+ import * as supertest from 'supertest' ;
4
5
5
6
const projectConfig : ServeConfig & IBuildOptions = {
6
7
name : 'example project 1' ,
@@ -24,12 +25,36 @@ const projectConfig: ServeConfig & IBuildOptions = {
24
25
folderPath : __dirname ,
25
26
} ,
26
27
types : [ APIProviderType . RESTFUL ] ,
28
+ executor : {
29
+ type : 'pg-mem' ,
30
+ } ,
31
+ extensions : {
32
+ mockEx : path . resolve ( __dirname , '..' , 'mockExtensions' ) ,
33
+ } ,
34
+ 'rate-limit' : {
35
+ interval : { min : 1 } ,
36
+ max : 10000 ,
37
+ } ,
27
38
} ;
28
39
40
+ let server : VulcanServer ;
41
+
42
+ afterEach ( async ( ) => {
43
+ await server . close ( ) ;
44
+ } ) ;
45
+
29
46
it ( 'Example1: Build and server should work' , async ( ) => {
30
47
const builder = new VulcanBuilder ( ) ;
31
48
await builder . build ( projectConfig ) ;
32
- const server = new VulcanServer ( projectConfig ) ;
33
- await server . start ( 3000 ) ;
34
- await server . close ( ) ;
49
+ server = new VulcanServer ( projectConfig ) ;
50
+ const httpServer = await server . start ( 3000 ) ;
51
+
52
+ const agent = supertest ( httpServer ) ;
53
+ const result = await agent . get (
54
+ '/user?id=436193eb-f686-4105-ad7b-b5945276c14a'
55
+ ) ;
56
+ expect ( result . body ) . toContainEqual ( {
57
+ id : '436193eb-f686-4105-ad7b-b5945276c14a' ,
58
+ name : 'ivan' ,
59
+ } ) ;
35
60
} , 10000 ) ;
0 commit comments