@@ -23,12 +23,10 @@ import {ErrorsApiTransport} from './errors-transport';
2323
2424const inject = require ( 'require-inject' ) ;
2525
26- const winston3 = require ( 'winston' ) ;
27- const winston2 = require ( '../../test/winston-2/node_modules/winston' ) ;
26+ const winston = require ( 'winston' ) ;
2827
2928const { Logging} = require ( '@google-cloud/logging' ) ;
3029const logging = new Logging ( ) ;
31- const LoggingWinston = require ( '../src/index' ) . LoggingWinston ;
3230
3331const WRITE_CONSISTENCY_DELAY_MS = 90000 ;
3432
@@ -84,58 +82,7 @@ describe('LoggingWinston', function() {
8482 args : any [ ] ; level : string ; verify : ( entry : types . StackdriverEntry ) => void ;
8583 } ;
8684
87- describe ( 'log winston 2' , ( ) => {
88- const testData = commonTestData . concat ( [
89- {
90- args : [ new Error ( 'fourth' ) ] ,
91- level : 'error' ,
92- verify : ( entry : types . StackdriverEntry ) => {
93- assert ( ( entry . data as {
94- message : string
95- } ) . message . startsWith ( 'Error: fourth' ) ) ;
96- } ,
97- } ,
98- {
99- args : [ 'fifth message' , new Error ( 'fifth' ) ] ,
100- level : 'error' ,
101- verify : ( entry : types . StackdriverEntry ) => {
102- assert ( ( entry . data as {
103- message : string
104- } ) . message . startsWith ( 'fifth message Error: fifth' ) ) ;
105- } ,
106- } ,
107- ] as typeof commonTestData ) ;
108-
109- const LOG_NAME = logName ( 'logging_winston_2_system_tests' ) ;
110- const LoggingWinston = inject ( '../src/index' , {
111- winston : winston2 ,
112- 'winston/package.json' : { version : '2.2.0' }
113- } ) . LoggingWinston ;
114-
115- const logger = new winston2 . Logger ( {
116- transports : [ new LoggingWinston ( { logName : LOG_NAME } ) ] ,
117- } ) ;
118-
119- it ( 'should properly write log entries' , async ( ) => {
120- const start = Date . now ( ) ;
121- testData . forEach ( ( test ) => {
122- // logger does not have index signature.
123- // tslint:disable-next-line:no-any
124- ( logger as any ) [ test . level ] . apply ( logger , test . args ) ;
125- } ) ;
126-
127- const entries = await pollLogs (
128- LOG_NAME , start , testData . length , WRITE_CONSISTENCY_DELAY_MS ) ;
129- assert . strictEqual ( entries . length , testData . length ) ;
130- entries . reverse ( ) . forEach ( ( entry , index ) => {
131- const test = testData [ index ] ;
132- test . verify ( entry ) ;
133- } ) ;
134- } ) ;
135- } ) ;
136-
137-
138- describe ( 'log winston 3' , ( ) => {
85+ describe ( 'log' , ( ) => {
13986 const testData = commonTestData . concat ( [
14087 {
14188 args : [ new Error ( 'fourth' ) ] ,
@@ -161,13 +108,12 @@ describe('LoggingWinston', function() {
161108 } ,
162109 ] as TestData [ ] ) ;
163110
164- const LOG_NAME = logName ( 'logging_winston_3_system_tests ' ) ;
111+ const LOG_NAME = logName ( 'logging_winston_system_tests ' ) ;
165112 const LoggingWinston = inject ( '../src/index' , {
166- winston : winston3 ,
167- 'winston/package.json' : { version : '3.0.0' }
113+ winston,
168114 } ) . LoggingWinston ;
169115
170- const logger = winston3 . createLogger ( {
116+ const logger = winston . createLogger ( {
171117 transports : [ new LoggingWinston ( { logName : LOG_NAME } ) ] ,
172118 } ) ;
173119
@@ -194,42 +140,14 @@ describe('LoggingWinston', function() {
194140 const ERROR_REPORTING_POLL_TIMEOUT = WRITE_CONSISTENCY_DELAY_MS ;
195141 const errorsTransport = new ErrorsApiTransport ( ) ;
196142
197- it ( 'reports errors when logging errors with winston2' , async ( ) => {
198- const start = Date . now ( ) ;
199- const service = `logging-winston-system-test-winston2-${ UUID } ` ;
200- const LoggingWinston = inject ( '../src/index' , {
201- winston : winston2 ,
202- 'winston/package.json' : { version : '2.2.0' }
203- } ) . LoggingWinston ;
204-
205- const logger = new winston2 . Logger ( {
206- transports : [ new LoggingWinston (
207- { logName : LOG_NAME , serviceContext : { service, version : 'none' } } ) ] ,
208- } ) ;
209-
210- const message = `an error at ${ Date . now ( ) } ` ;
211-
212- logger . error ( 'an error' , new Error ( message ) ) ;
213-
214- const errors = await errorsTransport . pollForNewEvents (
215- service , start , ERROR_REPORTING_POLL_TIMEOUT ) ;
216-
217- assert . strictEqual ( errors . length , 1 ) ;
218- const errEvent = errors [ 0 ] ;
219-
220- assert . strictEqual ( errEvent . serviceContext . service , service ) ;
221- assert ( errEvent . message . startsWith ( `an error Error: ${ message } ` ) ) ;
222- } ) ;
223-
224- it ( 'reports errors when logging errors with winston3' , async ( ) => {
143+ it ( 'reports errors' , async ( ) => {
225144 const start = Date . now ( ) ;
226145 const service = `logging-winston-system-test-winston3-${ UUID } ` ;
227146 const LoggingWinston = inject ( '../src/index' , {
228- winston : winston3 ,
229- 'winston/package.json' : { version : '3.0.0' }
147+ winston,
230148 } ) . LoggingWinston ;
231149
232- const logger = winston3 . createLogger ( {
150+ const logger = winston . createLogger ( {
233151 transports : [ new LoggingWinston (
234152 { logName : LOG_NAME , serviceContext : { service, version : 'none' } } ) ] ,
235153 } ) ;
0 commit comments