@@ -3,7 +3,8 @@ import assert from 'assert';
3
3
import { Readable } from 'stream' ;
4
4
import { promisify } from 'util' ;
5
5
import { FileBreadcrumbsStorage } from '../../src/breadcrumbs/FileBreadcrumbsStorage.js' ;
6
- import { mockStreamFileSystem } from '../_mocks/storage.js' ;
6
+ import { NodeFsBacktraceFileAttachmentFactory } from '../../src/index.js' ;
7
+ import { mockNodeStorageAndFs } from '../_mocks/storage.js' ;
7
8
8
9
async function readToEnd ( readable : Readable ) {
9
10
return new Promise < Buffer > ( ( resolve , reject ) => {
@@ -33,8 +34,8 @@ const nextTick = promisify(process.nextTick);
33
34
34
35
describe ( 'FileBreadcrumbsStorage' , ( ) => {
35
36
it ( 'should return added breadcrumbs' , async ( ) => {
36
- const fs = mockStreamFileSystem ( ) ;
37
- const session = new SessionFiles ( fs , 'sessionId' ) ;
37
+ const fs = mockNodeStorageAndFs ( ) ;
38
+ const session = new SessionFiles ( fs , { id : 'sessionId' , timestamp : Date . now ( ) } ) ;
38
39
39
40
const breadcrumbs : RawBreadcrumb [ ] = [
40
41
{
@@ -86,7 +87,7 @@ describe('FileBreadcrumbsStorage', () => {
86
87
} ,
87
88
] ;
88
89
89
- const storage = new FileBreadcrumbsStorage ( session , fs , {
90
+ const storage = new FileBreadcrumbsStorage ( session , fs , new NodeFsBacktraceFileAttachmentFactory ( fs ) , {
90
91
maximumBreadcrumbs : 100 ,
91
92
} ) ;
92
93
@@ -107,8 +108,8 @@ describe('FileBreadcrumbsStorage', () => {
107
108
} ) ;
108
109
109
110
it ( 'should return added breadcrumbs in two attachments' , async ( ) => {
110
- const fs = mockStreamFileSystem ( ) ;
111
- const session = new SessionFiles ( fs , 'sessionId' ) ;
111
+ const fs = mockNodeStorageAndFs ( ) ;
112
+ const session = new SessionFiles ( fs , { id : 'sessionId' , timestamp : Date . now ( ) } ) ;
112
113
113
114
const breadcrumbs : RawBreadcrumb [ ] = [
114
115
{
@@ -163,7 +164,7 @@ describe('FileBreadcrumbsStorage', () => {
163
164
} ,
164
165
] ;
165
166
166
- const storage = new FileBreadcrumbsStorage ( session , fs , {
167
+ const storage = new FileBreadcrumbsStorage ( session , fs , new NodeFsBacktraceFileAttachmentFactory ( fs ) , {
167
168
maximumBreadcrumbs : 4 ,
168
169
} ) ;
169
170
@@ -189,8 +190,8 @@ describe('FileBreadcrumbsStorage', () => {
189
190
} ) ;
190
191
191
192
it ( 'should return no more than maximumBreadcrumbs breadcrumbs' , async ( ) => {
192
- const fs = mockStreamFileSystem ( ) ;
193
- const session = new SessionFiles ( fs , 'sessionId' ) ;
193
+ const fs = mockNodeStorageAndFs ( ) ;
194
+ const session = new SessionFiles ( fs , { id : 'sessionId' , timestamp : Date . now ( ) } ) ;
194
195
195
196
const breadcrumbs : RawBreadcrumb [ ] = [
196
197
{
@@ -235,7 +236,7 @@ describe('FileBreadcrumbsStorage', () => {
235
236
} ,
236
237
] ;
237
238
238
- const storage = new FileBreadcrumbsStorage ( session , fs , {
239
+ const storage = new FileBreadcrumbsStorage ( session , fs , new NodeFsBacktraceFileAttachmentFactory ( fs ) , {
239
240
maximumBreadcrumbs : 2 ,
240
241
} ) ;
241
242
@@ -261,8 +262,8 @@ describe('FileBreadcrumbsStorage', () => {
261
262
} ) ;
262
263
263
264
it ( 'should return breadcrumbs up to the json size' , async ( ) => {
264
- const fs = mockStreamFileSystem ( ) ;
265
- const session = new SessionFiles ( fs , 'sessionId' ) ;
265
+ const fs = mockNodeStorageAndFs ( ) ;
266
+ const session = new SessionFiles ( fs , { id : 'sessionId' , timestamp : Date . now ( ) } ) ;
266
267
267
268
const breadcrumbs : RawBreadcrumb [ ] = [
268
269
{
@@ -302,7 +303,7 @@ describe('FileBreadcrumbsStorage', () => {
302
303
} ,
303
304
] ;
304
305
305
- const storage = new FileBreadcrumbsStorage ( session , fs , {
306
+ const storage = new FileBreadcrumbsStorage ( session , fs , new NodeFsBacktraceFileAttachmentFactory ( fs ) , {
306
307
maximumBreadcrumbs : 100 ,
307
308
maximumTotalBreadcrumbsSize : JSON . stringify ( expectedMain [ 0 ] ) . length + 10 ,
308
309
} ) ;
@@ -329,8 +330,8 @@ describe('FileBreadcrumbsStorage', () => {
329
330
} ) ;
330
331
331
332
it ( 'should return attachments with a valid name from getAttachments' , async ( ) => {
332
- const fs = mockStreamFileSystem ( ) ;
333
- const session = new SessionFiles ( fs , 'sessionId' ) ;
333
+ const fs = mockNodeStorageAndFs ( ) ;
334
+ const session = new SessionFiles ( fs , { id : 'sessionId' , timestamp : Date . now ( ) } ) ;
334
335
335
336
const breadcrumbs : RawBreadcrumb [ ] = [
336
337
{
@@ -354,7 +355,7 @@ describe('FileBreadcrumbsStorage', () => {
354
355
} ,
355
356
] ;
356
357
357
- const storage = new FileBreadcrumbsStorage ( session , fs , {
358
+ const storage = new FileBreadcrumbsStorage ( session , fs , new NodeFsBacktraceFileAttachmentFactory ( fs ) , {
358
359
maximumBreadcrumbs : 4 ,
359
360
} ) ;
360
361
@@ -373,8 +374,8 @@ describe('FileBreadcrumbsStorage', () => {
373
374
} ) ;
374
375
375
376
it ( 'should return attachments with a valid name from getAttachmentProviders' , async ( ) => {
376
- const fs = mockStreamFileSystem ( ) ;
377
- const session = new SessionFiles ( fs , 'sessionId' ) ;
377
+ const fs = mockNodeStorageAndFs ( ) ;
378
+ const session = new SessionFiles ( fs , { id : 'sessionId' , timestamp : Date . now ( ) } ) ;
378
379
379
380
const breadcrumbs : RawBreadcrumb [ ] = [
380
381
{
@@ -398,7 +399,7 @@ describe('FileBreadcrumbsStorage', () => {
398
399
} ,
399
400
] ;
400
401
401
- const storage = new FileBreadcrumbsStorage ( session , fs , {
402
+ const storage = new FileBreadcrumbsStorage ( session , fs , new NodeFsBacktraceFileAttachmentFactory ( fs ) , {
402
403
maximumBreadcrumbs : 4 ,
403
404
} ) ;
404
405
0 commit comments