@@ -24,10 +24,8 @@ describe('HTTP request handler', () => {
2424 repository,
2525 domain : false ,
2626 logger : {
27- level : process . env . DEBUG === '*' || process . env . DEBUG ?. includes ( 'test' )
28- ? 'debug'
29- : 'error'
30- }
27+ level : process . env . DEBUG === '*' || process . env . DEBUG ?. includes ( 'test' ) ? 'debug' : 'error' ,
28+ } ,
3129 } )
3230 baseUrl = await app . listen ( )
3331 } )
@@ -48,20 +46,35 @@ describe('HTTP request handler', () => {
4846
4947 describe ( 'GET /samples/{providerId}/{pieceCid}' , ( ) => {
5048 it ( 'returns the first payload block from the index' , async ( ) => {
51- await repository . addPiecePayloadBlocks ( 'provider-id' , 'piece-cid' , 'payload-cid-1' , 'payload-cid-2' )
52- await repository . addPiecePayloadBlocks ( 'provider-id2' , 'piece-cid' , 'payload-cid-1' , 'payload-cid-2' )
53- await repository . addPiecePayloadBlocks ( 'provider-id' , 'piece-cid2' , 'payload-cid-1' , 'payload-cid-2' )
49+ await repository . addPiecePayloadBlocks (
50+ 'provider-id' ,
51+ 'piece-cid' ,
52+ 'payload-cid-1' ,
53+ 'payload-cid-2' ,
54+ )
55+ await repository . addPiecePayloadBlocks (
56+ 'provider-id2' ,
57+ 'piece-cid' ,
58+ 'payload-cid-1' ,
59+ 'payload-cid-2' ,
60+ )
61+ await repository . addPiecePayloadBlocks (
62+ 'provider-id' ,
63+ 'piece-cid2' ,
64+ 'payload-cid-1' ,
65+ 'payload-cid-2' ,
66+ )
5467
5568 const res = await fetch ( new URL ( '/sample/provider-id/piece-cid' , baseUrl ) )
5669 await assertResponseStatus ( res , 200 )
5770 const body = await res . json ( )
5871
5972 assert . deepStrictEqual ( body , {
60- samples : [ 'payload-cid-1' ]
73+ samples : [ 'payload-cid-1' ] ,
6174 } )
6275 assert . strictEqual (
6376 res . headers . get ( 'cache-control' ) ,
64- `public, max-age=${ 24 * 3600 } , immutable`
77+ `public, max-age=${ 24 * 3600 } , immutable` ,
6578 )
6679 } )
6780
@@ -73,12 +86,9 @@ describe('HTTP request handler', () => {
7386 const body = await res . json ( )
7487
7588 assert . deepStrictEqual ( body , {
76- error : 'PROVIDER_OR_PIECE_NOT_FOUND'
89+ error : 'PROVIDER_OR_PIECE_NOT_FOUND' ,
7790 } )
78- assert . strictEqual (
79- res . headers . get ( 'cache-control' ) ,
80- `public, max-age=${ 60 } `
81- )
91+ assert . strictEqual ( res . headers . get ( 'cache-control' ) , `public, max-age=${ 60 } ` )
8292 } )
8393
8494 it ( 'returns error when provider piece is not found' , async ( ) => {
@@ -89,12 +99,9 @@ describe('HTTP request handler', () => {
8999 const body = await res . json ( )
90100
91101 assert . deepStrictEqual ( body , {
92- error : 'PROVIDER_OR_PIECE_NOT_FOUND'
102+ error : 'PROVIDER_OR_PIECE_NOT_FOUND' ,
93103 } )
94- assert . strictEqual (
95- res . headers . get ( 'cache-control' ) ,
96- `public, max-age=${ 60 } `
97- )
104+ assert . strictEqual ( res . headers . get ( 'cache-control' ) , `public, max-age=${ 60 } ` )
98105 } )
99106 } )
100107
@@ -115,20 +122,17 @@ describe('HTTP request handler', () => {
115122 lastHeadWalkedFrom : 'last-head' ,
116123 adsMissingPieceCID : 0 ,
117124 entriesNotRetrievable : 0 ,
118- piecesIndexed : 1
125+ piecesIndexed : 1 ,
119126 } )
120127
121- assert . strictEqual (
122- res . headers . get ( 'cache-control' ) ,
123- `public, max-age=${ 60 } `
124- )
128+ assert . strictEqual ( res . headers . get ( 'cache-control' ) , `public, max-age=${ 60 } ` )
125129 } )
126130
127131 it ( 'returns error for an unknown provider' , async ( ) => {
128132 await repository . setWalkerState ( 'provider-id' , {
129133 status : 'walking' ,
130134 tail : 'tail' ,
131- lastHead : 'last-head'
135+ lastHead : 'last-head' ,
132136 } )
133137 await repository . addPiecePayloadBlocks ( 'provider-id' , 'piece-cid' , 'bafy1' )
134138
@@ -138,13 +142,10 @@ describe('HTTP request handler', () => {
138142
139143 assert . deepStrictEqual ( body , {
140144 providerId : 'unknown-provider-id' ,
141- ingestionStatus : 'Unknown provider ID'
145+ ingestionStatus : 'Unknown provider ID' ,
142146 } )
143147
144- assert . strictEqual (
145- res . headers . get ( 'cache-control' ) ,
146- `public, max-age=${ 60 } `
147- )
148+ assert . strictEqual ( res . headers . get ( 'cache-control' ) , `public, max-age=${ 60 } ` )
148149 } )
149150
150151 it ( 'returns "head" as "lastHead" when the initial walk has not finished yet' , async ( ) => {
@@ -161,21 +162,18 @@ describe('HTTP request handler', () => {
161162 lastHeadWalkedFrom : 'head' ,
162163 adsMissingPieceCID : 0 ,
163164 entriesNotRetrievable : 0 ,
164- piecesIndexed : 1
165+ piecesIndexed : 1 ,
165166 } )
166167
167- assert . strictEqual (
168- res . headers . get ( 'cache-control' ) ,
169- `public, max-age=${ 60 } `
170- )
168+ assert . strictEqual ( res . headers . get ( 'cache-control' ) , `public, max-age=${ 60 } ` )
171169 } )
172170
173171 it ( 'returns the number of adsMissingPieceCID and entriesNotRetrievable' , async ( ) => {
174172 await repository . setWalkerState ( 'provider-id' , {
175173 status : 'walking' ,
176174 head : 'head' ,
177175 entriesNotRetrievable : 10 ,
178- adsMissingPieceCID : 20
176+ adsMissingPieceCID : 20 ,
179177 } )
180178
181179 const res = await fetch ( new URL ( '/ingestion-status/provider-id' , baseUrl ) )
@@ -188,13 +186,10 @@ describe('HTTP request handler', () => {
188186 lastHeadWalkedFrom : 'head' ,
189187 entriesNotRetrievable : 10 ,
190188 adsMissingPieceCID : 20 ,
191- piecesIndexed : 0
189+ piecesIndexed : 0 ,
192190 } )
193191
194- assert . strictEqual (
195- res . headers . get ( 'cache-control' ) ,
196- `public, max-age=${ 60 } `
197- )
192+ assert . strictEqual ( res . headers . get ( 'cache-control' ) , `public, max-age=${ 60 } ` )
198193 } )
199194 } )
200195} )
0 commit comments