@@ -27,101 +27,103 @@ describe('MongodbInstance', () => {
2727 version = tmpVersion ;
2828 } ) ;
2929
30- it ( 'should prepare command args' , ( ) => {
31- const inst = new MongodbInstance ( {
32- instance : {
33- port : 27333 ,
34- dbPath : tmpDir . name ,
35- storageEngine : 'ephemeralForTest' ,
36- } ,
30+ describe ( 'prepareCommandArgs' , ( ) => {
31+ it ( 'should prepare command args' , ( ) => {
32+ const inst = new MongodbInstance ( {
33+ instance : {
34+ port : 27333 ,
35+ dbPath : tmpDir . name ,
36+ storageEngine : 'ephemeralForTest' ,
37+ } ,
38+ } ) ;
39+ expect ( inst . prepareCommandArgs ( ) ) . toEqual ( [
40+ '--port' ,
41+ '27333' ,
42+ '--dbpath' ,
43+ tmpDir . name ,
44+ '--storageEngine' ,
45+ 'ephemeralForTest' ,
46+ '--noauth' ,
47+ ] ) ;
3748 } ) ;
38- expect ( inst . prepareCommandArgs ( ) ) . toEqual ( [
39- '--port' ,
40- '27333' ,
41- '--dbpath' ,
42- tmpDir . name ,
43- '--storageEngine' ,
44- 'ephemeralForTest' ,
45- '--noauth' ,
46- ] ) ;
47- } ) ;
4849
49- it ( 'should allow specifying replSet' , ( ) => {
50- const inst = new MongodbInstance ( {
51- instance : {
52- port : 27555 ,
53- dbPath : tmpDir . name ,
54- replSet : 'testset' ,
55- } ,
50+ it ( 'should allow specifying replSet' , ( ) => {
51+ const inst = new MongodbInstance ( {
52+ instance : {
53+ port : 27555 ,
54+ dbPath : tmpDir . name ,
55+ replSet : 'testset' ,
56+ } ,
57+ } ) ;
58+ expect ( inst . prepareCommandArgs ( ) ) . toEqual ( [
59+ '--port' ,
60+ '27555' ,
61+ '--dbpath' ,
62+ tmpDir . name ,
63+ '--noauth' ,
64+ '--replSet' ,
65+ 'testset' ,
66+ ] ) ;
5667 } ) ;
57- expect ( inst . prepareCommandArgs ( ) ) . toEqual ( [
58- '--port' ,
59- '27555' ,
60- '--dbpath' ,
61- tmpDir . name ,
62- '--noauth' ,
63- '--replSet' ,
64- 'testset' ,
65- ] ) ;
66- } ) ;
6768
68- it ( 'should be able to enable auth' , ( ) => {
69- const inst = new MongodbInstance ( {
70- instance : {
71- port : 27555 ,
72- dbPath : tmpDir . name ,
73- auth : true ,
74- } ,
69+ it ( 'should be able to enable auth' , ( ) => {
70+ const inst = new MongodbInstance ( {
71+ instance : {
72+ port : 27555 ,
73+ dbPath : tmpDir . name ,
74+ auth : true ,
75+ } ,
76+ } ) ;
77+ expect ( inst . prepareCommandArgs ( ) ) . toEqual ( [
78+ '--port' ,
79+ '27555' ,
80+ '--dbpath' ,
81+ tmpDir . name ,
82+ '--auth' ,
83+ ] ) ;
7584 } ) ;
76- expect ( inst . prepareCommandArgs ( ) ) . toEqual ( [
77- '--port' ,
78- '27555' ,
79- '--dbpath' ,
80- tmpDir . name ,
81- '--auth' ,
82- ] ) ;
83- } ) ;
8485
85- it ( 'should be able to pass arbitrary args' , ( ) => {
86- const args = [ '--notablescan' , '--nounixsocket' ] ;
87- const inst = new MongodbInstance ( {
88- instance : {
89- port : 27555 ,
90- dbPath : tmpDir . name ,
91- args,
92- } ,
86+ it ( 'should be able to pass arbitrary args' , ( ) => {
87+ const args = [ '--notablescan' , '--nounixsocket' ] ;
88+ const inst = new MongodbInstance ( {
89+ instance : {
90+ port : 27555 ,
91+ dbPath : tmpDir . name ,
92+ args,
93+ } ,
94+ } ) ;
95+ expect ( inst . prepareCommandArgs ( ) ) . toEqual (
96+ [ '--port' , '27555' , '--dbpath' , tmpDir . name , '--noauth' ] . concat ( args )
97+ ) ;
9398 } ) ;
94- expect ( inst . prepareCommandArgs ( ) ) . toEqual (
95- [ '--port' , '27555' , '--dbpath' , tmpDir . name , '--noauth' ] . concat ( args )
96- ) ;
97- } ) ;
9899
99- it ( 'should throw an error if no port is provided' , ( ) => {
100- const inst = new MongodbInstance ( {
101- instance : {
102- dbPath : tmpDir . name ,
103- } ,
100+ it ( 'should throw an error if no port is provided' , ( ) => {
101+ const inst = new MongodbInstance ( {
102+ instance : {
103+ dbPath : tmpDir . name ,
104+ } ,
105+ } ) ;
106+ try {
107+ inst . prepareCommandArgs ( ) ;
108+ fail ( 'Expected prepareCommandArgs to throw' ) ;
109+ } catch ( err ) {
110+ expect ( err . message ) . toEqual ( '"instanceOpts.port" is required to be set!' ) ;
111+ }
104112 } ) ;
105- try {
106- inst . prepareCommandArgs ( ) ;
107- fail ( 'Expected prepareCommandArgs to throw' ) ;
108- } catch ( err ) {
109- expect ( err . message ) . toEqual ( '"instanceOpts.port" is required to be set!' ) ;
110- }
111- } ) ;
112113
113- it ( 'should throw an error if no dbpath is provided' , ( ) => {
114- const inst = new MongodbInstance ( {
115- instance : {
116- port : 27555 ,
117- } ,
114+ it ( 'should throw an error if no dbpath is provided' , ( ) => {
115+ const inst = new MongodbInstance ( {
116+ instance : {
117+ port : 27555 ,
118+ } ,
119+ } ) ;
120+ try {
121+ inst . prepareCommandArgs ( ) ;
122+ fail ( 'Expected prepareCommandArgs to throw' ) ;
123+ } catch ( err ) {
124+ expect ( err . message ) . toEqual ( '"instanceOpts.dbPath" is required to be set!' ) ;
125+ }
118126 } ) ;
119- try {
120- inst . prepareCommandArgs ( ) ;
121- fail ( 'Expected prepareCommandArgs to throw' ) ;
122- } catch ( err ) {
123- expect ( err . message ) . toEqual ( '"instanceOpts.dbPath" is required to be set!' ) ;
124- }
125127 } ) ;
126128
127129 it ( 'should start instance on port 27333' , async ( ) => {
0 commit comments