@@ -163,6 +163,56 @@ describe('get', () => {
163
163
164
164
expect ( mockStore . fulfilled ) . toBeTruthy ( )
165
165
} )
166
+
167
+ test ( 'Reads from a store with a legacy namespace' , async ( ) => {
168
+ const mockStore = new MockFetch ( )
169
+ . get ( {
170
+ headers : { accept : 'application/json;type=signed-url' , authorization : `Bearer ${ apiToken } ` } ,
171
+ response : new Response ( JSON . stringify ( { url : signedURL } ) ) ,
172
+ url : `https://api.netlify.com/api/v1/blobs/${ siteID } /oldie/${ key } ` ,
173
+ } )
174
+ . get ( {
175
+ response : new Response ( value ) ,
176
+ url : signedURL ,
177
+ } )
178
+ . get ( {
179
+ headers : { accept : 'application/json;type=signed-url' , authorization : `Bearer ${ apiToken } ` } ,
180
+ response : new Response ( JSON . stringify ( { url : signedURL } ) ) ,
181
+ url : `https://api.netlify.com/api/v1/blobs/${ siteID } /oldie/${ key } ` ,
182
+ } )
183
+ . get ( {
184
+ response : new Response ( value ) ,
185
+ url : signedURL ,
186
+ } )
187
+ . get ( {
188
+ headers : { accept : 'application/json;type=signed-url' , authorization : `Bearer ${ apiToken } ` } ,
189
+ response : new Response ( JSON . stringify ( { url : signedURL } ) ) ,
190
+ url : `https://api.netlify.com/api/v1/blobs/${ siteID } /oldie/${ complexKey } ` ,
191
+ } )
192
+ . get ( {
193
+ response : new Response ( value ) ,
194
+ url : signedURL ,
195
+ } )
196
+
197
+ globalThis . fetch = mockStore . fetch
198
+
199
+ const blobs = getStore ( {
200
+ name : 'netlify-internal/legacy-namespace/oldie' ,
201
+ token : apiToken ,
202
+ siteID,
203
+ } )
204
+
205
+ const string = await blobs . get ( key )
206
+ expect ( string ) . toBe ( value )
207
+
208
+ const stream = await blobs . get ( key , { type : 'stream' } )
209
+ expect ( await streamToString ( stream as unknown as NodeJS . ReadableStream ) ) . toBe ( value )
210
+
211
+ const string2 = await blobs . get ( complexKey )
212
+ expect ( string2 ) . toBe ( value )
213
+
214
+ expect ( mockStore . fulfilled ) . toBeTruthy ( )
215
+ } )
166
216
} )
167
217
168
218
describe ( 'With edge credentials' , ( ) => {
0 commit comments