@@ -47,11 +47,14 @@ export class DriverTests {
4747 { id : 4 , amount : 500 , status : null } ,
4848 ] ;
4949
50- public static CSV_ROWS = dedent `
51- orders__status,orders__amount
52- new,300
53- processed,400
54- ` ;
50+ protected getExpectedCsvRows ( ) {
51+ return dedent `
52+ orders__status,orders__amount
53+ new,300
54+ processed,400
55+ ,500
56+ ` ;
57+ }
5558
5659 public async testQuery ( ) {
5760 const rows = await this . driver . query ( DriverTests . QUERY , [ ] ) ;
@@ -73,16 +76,16 @@ export class DriverTests {
7376 SELECT orders.status AS orders__status, sum(orders.amount) AS orders__amount
7477 FROM (${ DriverTests . QUERY } ) AS orders
7578 GROUP BY 1
76- ORDER BY 1
79+ ORDER BY 2
7780 ` ;
7881 const tableName = await this . createUnloadTable ( query ) ;
7982 assert ( this . driver . unload ) ;
8083 const data = await this . driver . unload ( tableName , { maxFileSize : 64 } ) ;
8184 expect ( data . csvFile . length ) . toEqual ( 1 ) ;
8285 const string = await downloadAndGunzip ( data . csvFile [ 0 ] ) ;
8386 const expectedRows = this . options . csvNoHeader
84- ? DriverTests . skipFirstLine ( DriverTests . CSV_ROWS )
85- : DriverTests . CSV_ROWS ;
87+ ? DriverTests . skipFirstLine ( this . getExpectedCsvRows ( ) )
88+ : this . getExpectedCsvRows ( ) ;
8689 expect ( string . trim ( ) ) . toEqual ( expectedRows ) ;
8790 }
8891
@@ -171,15 +174,17 @@ export class DriverTests {
171174 return text . split ( '\n' ) . slice ( 1 ) . join ( '\n' ) ;
172175 }
173176
174- private static rowsToString ( rows : Record < string , any > [ ] ) : Record < string , string > [ ] {
175- const result : Record < string , string > [ ] = [ ] ;
177+ private static rowsToString ( rows : Record < string , any > [ ] ) : Record < string , string | null > [ ] {
178+ const result : Record < string , string | null > [ ] = [ ] ;
179+
176180 for ( const row of rows ) {
177181 const newRow : Record < string , string > = { } ;
178182 for ( const k of Object . keys ( row ) ) {
179- newRow [ k ] = row [ k ] . toString ( ) ;
183+ newRow [ k ] = row [ k ] === null ? null : row [ k ] . toString ( ) ;
180184 }
181185 result . push ( newRow ) ;
182186 }
187+
183188 return result ;
184189 }
185190}
0 commit comments