@@ -45,19 +45,15 @@ describe("[Asset Worker] Fetching assets from KV", () => {
4545
4646 await expect ( ( ) =>
4747 getAssetWithMetadataFromKV ( mockKVNamespace , "abcd" )
48- ) . rejects . toThrowError (
49- "Requested asset abcd could not be fetched from KV namespace."
50- ) ;
48+ ) . rejects . toThrowError ( "KV GET abcd failed." ) ;
5149 } ) ;
5250
5351 it ( "should retry once by default if something went wrong while fetching the asset" , async ( ) => {
5452 spy . mockReturnValue ( Promise . reject ( "Oeps! Something went wrong" ) ) ;
5553
5654 await expect ( ( ) =>
5755 getAssetWithMetadataFromKV ( mockKVNamespace , "abcd" )
58- ) . rejects . toThrowError (
59- "Requested asset abcd could not be fetched from KV namespace."
60- ) ;
56+ ) . rejects . toThrowError ( "KV GET abcd failed." ) ;
6157 expect ( spy ) . toHaveBeenCalledTimes ( 2 ) ;
6258 } ) ;
6359
@@ -66,12 +62,21 @@ describe("[Asset Worker] Fetching assets from KV", () => {
6662
6763 await expect ( ( ) =>
6864 getAssetWithMetadataFromKV ( mockKVNamespace , "abcd" , undefined , 2 )
69- ) . rejects . toThrowError (
70- "Requested asset abcd could not be fetched from KV namespace."
71- ) ;
65+ ) . rejects . toThrowError ( "KV GET abcd failed." ) ;
7266 expect ( spy ) . toHaveBeenCalledTimes ( 3 ) ;
7367 } ) ;
7468
69+ it ( "should inject message with error" , async ( ) => {
70+ spy . mockReturnValue (
71+ Promise . reject ( new Error ( "Oeps! Something went wrong" ) )
72+ ) ;
73+
74+ await expect ( ( ) =>
75+ getAssetWithMetadataFromKV ( mockKVNamespace , "abcd" )
76+ ) . rejects . toThrowError ( "KV GET abcd failed: Oeps! Something went wrong" ) ;
77+ expect ( spy ) . toHaveBeenCalledTimes ( 2 ) ;
78+ } ) ;
79+
7580 it ( "should retry on 404 and cache with 30s ttl" , async ( ) => {
7681 let attempts = 0 ;
7782 spy . mockImplementation ( ( ) => {
0 commit comments