@@ -30,7 +30,7 @@ describe('setupLoggerAndTelemetry', () => {
30
30
31
31
it ( 'works' , ( ) => {
32
32
setupLoggerAndTelemetry ( logId , bus , ( ) => logger , ( ) => analytics ) ;
33
- expect ( logOutput ) . to . be . empty ;
33
+ expect ( logOutput ) . to . have . lengthOf ( 1 ) ;
34
34
expect ( analyticsOutput ) . to . be . empty ;
35
35
36
36
bus . emit ( 'mongosh:new-user' , userId , false ) ;
@@ -59,51 +59,52 @@ describe('setupLoggerAndTelemetry', () => {
59
59
60
60
bus . emit ( 'mongosh:start-loading-cli-scripts' , { usesShellOption : true } ) ;
61
61
bus . emit ( 'mongosh:api-load-file' , { nested : true , filename : 'foobar.js' } ) ;
62
- bus . emit ( 'mongosh:start-mongosh-repl' ) ;
62
+ bus . emit ( 'mongosh:start-mongosh-repl' , { version : '1.0.0' } ) ;
63
63
bus . emit ( 'mongosh:api-load-file' , { nested : false , filename : 'foobar.js' } ) ;
64
64
bus . emit ( 'mongosh:mongoshrc-load' ) ;
65
65
bus . emit ( 'mongosh:mongoshrc-mongorc-warn' ) ;
66
66
bus . emit ( 'mongosh:eval-cli-script' ) ;
67
67
68
- expect ( logOutput ) . to . have . lengthOf ( 24 ) ;
69
- expect ( logOutput [ 0 ] . msg ) . to . equal ( 'mongosh:update-user {"enableTelemetry":false}' ) ;
70
- expect ( logOutput [ 1 ] . msg ) . to . match ( / ^ m o n g o s h : c o n n e c t / ) ;
71
- expect ( logOutput [ 1 ] . msg ) . to . match ( / " s e s s i o n _ i d " : " 5 f b 3 c 2 0 e e 1 5 0 7 e 8 9 4 e 5 3 4 0 f 3 " / ) ;
72
- expect ( logOutput [ 1 ] . msg ) . to . match ( / " u s e r I d " : " 5 3 d e f e 9 9 5 f a 4 7 e 6 c 1 3 1 0 2 d 9 d " / ) ;
73
- expect ( logOutput [ 1 ] . msg ) . to . match ( / " c o n n e c t i o n U r i " : " m o n g o d b : \/ \/ l o c a l h o s t \/ " / ) ;
74
- expect ( logOutput [ 1 ] . msg ) . to . match ( / " i s _ l o c a l h o s t " : t r u e / ) ;
75
- expect ( logOutput [ 1 ] . msg ) . to . match ( / " i s _ a t l a s " : f a l s e / ) ;
76
- expect ( logOutput [ 1 ] . msg ) . to . match ( / " n o d e _ v e r s i o n " : " v 1 2 \. 1 9 \. 0 " / ) ;
77
- expect ( logOutput [ 2 ] . type ) . to . equal ( 'Error' ) ;
78
- expect ( logOutput [ 2 ] . msg ) . to . match ( / m e o w / ) ;
79
- expect ( logOutput [ 3 ] . msg ) . to . equal ( 'mongosh:help' ) ;
80
- expect ( logOutput [ 4 ] . msg ) . to . equal ( 'mongosh:use {"db":"admin"}' ) ;
81
- expect ( logOutput [ 5 ] . msg ) . to . equal ( 'mongosh:show {"method":"dbs"}' ) ;
82
- expect ( logOutput [ 6 ] . msg ) . to . equal ( 'mongosh:update-user {"enableTelemetry":true}' ) ;
83
- expect ( logOutput [ 7 ] . msg ) . to . match ( / ^ m o n g o s h : c o n n e c t / ) ;
84
- expect ( logOutput [ 8 ] . type ) . to . equal ( 'Error' ) ;
85
- expect ( logOutput [ 8 ] . msg ) . to . match ( / m e o w / ) ;
86
- expect ( logOutput [ 9 ] . msg ) . to . equal ( 'mongosh:help' ) ;
87
- expect ( logOutput [ 10 ] . msg ) . to . equal ( 'mongosh:use {"db":"admin"}' ) ;
88
- expect ( logOutput [ 11 ] . msg ) . to . equal ( 'mongosh:show {"method":"dbs"}' ) ;
89
- expect ( logOutput [ 12 ] . msg ) . to . equal ( 'mongosh:setCtx {"method":"setCtx"}' ) ;
90
- expect ( logOutput [ 13 ] . msg ) . to . match ( / ^ m o n g o s h : a p i - c a l l / ) ;
91
- expect ( logOutput [ 13 ] . msg ) . to . match ( / " d b " : " t e s t - 1 6 0 3 9 8 6 6 8 2 0 0 0 " / ) ;
68
+ expect ( logOutput ) . to . have . lengthOf ( 25 ) ;
69
+ expect ( logOutput [ 0 ] . msg ) . to . match ( / ^ m o n g o s h : s t a r t - l o g g i n g \{ " v e r s i o n " : " .+ " , " e x e c P a t h " : " .+ " , " i s C o m p i l e d B i n a r y " : .+ \} $ / ) ;
70
+ expect ( logOutput [ 1 ] . msg ) . to . equal ( 'mongosh:update-user {"enableTelemetry":false}' ) ;
71
+ expect ( logOutput [ 2 ] . msg ) . to . match ( / ^ m o n g o s h : c o n n e c t / ) ;
72
+ expect ( logOutput [ 2 ] . msg ) . to . match ( / " s e s s i o n _ i d " : " 5 f b 3 c 2 0 e e 1 5 0 7 e 8 9 4 e 5 3 4 0 f 3 " / ) ;
73
+ expect ( logOutput [ 2 ] . msg ) . to . match ( / " u s e r I d " : " 5 3 d e f e 9 9 5 f a 4 7 e 6 c 1 3 1 0 2 d 9 d " / ) ;
74
+ expect ( logOutput [ 2 ] . msg ) . to . match ( / " c o n n e c t i o n U r i " : " m o n g o d b : \/ \/ l o c a l h o s t \/ " / ) ;
75
+ expect ( logOutput [ 2 ] . msg ) . to . match ( / " i s _ l o c a l h o s t " : t r u e / ) ;
76
+ expect ( logOutput [ 2 ] . msg ) . to . match ( / " i s _ a t l a s " : f a l s e / ) ;
77
+ expect ( logOutput [ 2 ] . msg ) . to . match ( / " n o d e _ v e r s i o n " : " v 1 2 \. 1 9 \. 0 " / ) ;
78
+ expect ( logOutput [ 3 ] . type ) . to . equal ( 'Error' ) ;
79
+ expect ( logOutput [ 3 ] . msg ) . to . match ( / m e o w / ) ;
80
+ expect ( logOutput [ 4 ] . msg ) . to . equal ( 'mongosh:help' ) ;
81
+ expect ( logOutput [ 5 ] . msg ) . to . equal ( 'mongosh:use {"db":"admin"}' ) ;
82
+ expect ( logOutput [ 6 ] . msg ) . to . equal ( 'mongosh:show {"method":"dbs"}' ) ;
83
+ expect ( logOutput [ 7 ] . msg ) . to . equal ( 'mongosh:update-user {"enableTelemetry":true}' ) ;
84
+ expect ( logOutput [ 8 ] . msg ) . to . match ( / ^ m o n g o s h : c o n n e c t / ) ;
85
+ expect ( logOutput [ 9 ] . type ) . to . equal ( 'Error' ) ;
86
+ expect ( logOutput [ 9 ] . msg ) . to . match ( / m e o w / ) ;
87
+ expect ( logOutput [ 10 ] . msg ) . to . equal ( 'mongosh:help' ) ;
88
+ expect ( logOutput [ 11 ] . msg ) . to . equal ( 'mongosh:use {"db":"admin"}' ) ;
89
+ expect ( logOutput [ 12 ] . msg ) . to . equal ( 'mongosh:show {"method":"dbs"}' ) ;
90
+ expect ( logOutput [ 13 ] . msg ) . to . equal ( 'mongosh:setCtx {"method":"setCtx"}' ) ;
92
91
expect ( logOutput [ 14 ] . msg ) . to . match ( / ^ m o n g o s h : a p i - c a l l / ) ;
93
- expect ( logOutput [ 14 ] . msg ) . to . match ( / " e m a i l " : " < e m a i l > " / ) ;
94
- expect ( logOutput [ 15 ] . msg ) . to . match ( / ^ m o n g o s h : e v a l u a t e - i n p u t / ) ;
95
- expect ( logOutput [ 15 ] . msg ) . to . match ( / " i n p u t " : " 1 \+ 1 " / ) ;
96
- expect ( logOutput [ 16 ] . msg ) . to . match ( / " v e r s i o n " : " 3 .6 .1 " / ) ;
97
- expect ( logOutput [ 17 ] . msg ) . to . equal ( 'mongosh:start-loading-cli-scripts' ) ;
98
- expect ( logOutput [ 18 ] . msg ) . to . match ( / ^ m o n g o s h : a p i - l o a d - f i l e / ) ;
99
- expect ( logOutput [ 18 ] . msg ) . to . match ( / " n e s t e d " : t r u e / ) ;
100
- expect ( logOutput [ 18 ] . msg ) . to . match ( / " f i l e n a m e " : " f o o b a r .j s " / ) ;
101
- expect ( logOutput [ 19 ] . msg ) . to . equal ( 'mongosh:start-mongosh-repl' ) ;
102
- expect ( logOutput [ 20 ] . msg ) . to . match ( / " n e s t e d " : f a l s e / ) ;
103
- expect ( logOutput [ 20 ] . msg ) . to . match ( / " f i l e n a m e " : " f o o b a r .j s " / ) ;
104
- expect ( logOutput [ 21 ] . msg ) . to . equal ( 'mongosh:mongoshrc-load' ) ;
105
- expect ( logOutput [ 22 ] . msg ) . to . equal ( 'mongosh:mongoshrc-mongorc-warn' ) ;
106
- expect ( logOutput [ 23 ] . msg ) . to . equal ( 'mongosh:eval-cli-script' ) ;
92
+ expect ( logOutput [ 14 ] . msg ) . to . match ( / " d b " : " t e s t - 1 6 0 3 9 8 6 6 8 2 0 0 0 " / ) ;
93
+ expect ( logOutput [ 15 ] . msg ) . to . match ( / ^ m o n g o s h : a p i - c a l l / ) ;
94
+ expect ( logOutput [ 15 ] . msg ) . to . match ( / " e m a i l " : " < e m a i l > " / ) ;
95
+ expect ( logOutput [ 16 ] . msg ) . to . match ( / ^ m o n g o s h : e v a l u a t e - i n p u t / ) ;
96
+ expect ( logOutput [ 16 ] . msg ) . to . match ( / " i n p u t " : " 1 \+ 1 " / ) ;
97
+ expect ( logOutput [ 17 ] . msg ) . to . match ( / " v e r s i o n " : " 3 .6 .1 " / ) ;
98
+ expect ( logOutput [ 18 ] . msg ) . to . equal ( 'mongosh:start-loading-cli-scripts' ) ;
99
+ expect ( logOutput [ 19 ] . msg ) . to . match ( / ^ m o n g o s h : a p i - l o a d - f i l e / ) ;
100
+ expect ( logOutput [ 19 ] . msg ) . to . match ( / " n e s t e d " : t r u e / ) ;
101
+ expect ( logOutput [ 19 ] . msg ) . to . match ( / " f i l e n a m e " : " f o o b a r .j s " / ) ;
102
+ expect ( logOutput [ 20 ] . msg ) . to . equal ( 'mongosh:start-mongosh-repl {"version":"1.0.0"}' ) ;
103
+ expect ( logOutput [ 21 ] . msg ) . to . match ( / " n e s t e d " : f a l s e / ) ;
104
+ expect ( logOutput [ 21 ] . msg ) . to . match ( / " f i l e n a m e " : " f o o b a r .j s " / ) ;
105
+ expect ( logOutput [ 22 ] . msg ) . to . equal ( 'mongosh:mongoshrc-load' ) ;
106
+ expect ( logOutput [ 23 ] . msg ) . to . equal ( 'mongosh:mongoshrc-mongorc-warn' ) ;
107
+ expect ( logOutput [ 24 ] . msg ) . to . equal ( 'mongosh:eval-cli-script' ) ;
107
108
108
109
109
110
const mongosh_version = require ( '../package.json' ) . version ;
@@ -311,11 +312,11 @@ describe('setupLoggerAndTelemetry', () => {
311
312
setupLoggerAndTelemetry ( '5fb3c20ee1507e894e5340f3' , bus , ( ) => logger , ( ) => { throw new Error ( ) ; } ) ;
312
313
bus . emit ( 'mongosh:new-user' , userId , true ) ;
313
314
expect ( analyticsOutput ) . to . be . empty ;
314
- expect ( logOutput ) . to . have . lengthOf ( 1 ) ;
315
- expect ( logOutput [ 0 ] . type ) . to . equal ( 'Error' ) ;
316
- expect ( logOutput [ 0 ] . name ) . to . equal ( 'mongosh' ) ;
315
+ expect ( logOutput ) . to . have . lengthOf ( 2 ) ;
316
+ expect ( logOutput [ 1 ] . type ) . to . equal ( 'Error' ) ;
317
+ expect ( logOutput [ 1 ] . name ) . to . equal ( 'mongosh' ) ;
317
318
bus . emit ( 'mongosh:help' ) ;
318
319
expect ( analyticsOutput ) . to . be . empty ;
319
- expect ( logOutput ) . to . have . lengthOf ( 2 ) ;
320
+ expect ( logOutput ) . to . have . lengthOf ( 3 ) ;
320
321
} ) ;
321
322
} ) ;
0 commit comments