Skip to content

Commit 869e448

Browse files
committed
integration tests handle frameworks api
1 parent 0c91ea6 commit 869e448

File tree

1 file changed

+43
-17
lines changed

1 file changed

+43
-17
lines changed

tests/utils/fixture.ts

+43-17
Original file line numberDiff line numberDiff line change
@@ -298,28 +298,54 @@ export async function runPlugin(
298298
)
299299
}
300300

301-
await Promise.all([bundleEdgeFunctions(), bundleFunctions(), uploadBlobs(ctx, base.blobDir)])
301+
await Promise.all([bundleEdgeFunctions(), bundleFunctions(), uploadBlobs(ctx, base)])
302302

303303
return options
304304
}
305305

306-
export async function uploadBlobs(ctx: FixtureTestContext, blobsDir: string) {
307-
const files = await glob('**/*', {
308-
dot: true,
309-
cwd: blobsDir,
310-
})
306+
export async function uploadBlobs(ctx: FixtureTestContext, pluginContext: PluginContext) {
307+
if (pluginContext.blobsStrategy === 'frameworks-api') {
308+
const files = await glob('**/blob', {
309+
dot: true,
310+
cwd: pluginContext.blobDir,
311+
})
311312

312-
const keys = files.filter((file) => !basename(file).startsWith('$'))
313-
await Promise.all(
314-
keys.map(async (key) => {
315-
const { dir, base } = parse(key)
316-
const metaFile = join(blobsDir, dir, `$${base}.json`)
317-
const metadata = await readFile(metaFile, 'utf-8')
318-
.then((meta) => JSON.parse(meta))
319-
.catch(() => ({}))
320-
await ctx.blobStore.set(key, await readFile(join(blobsDir, key), 'utf-8'), { metadata })
321-
}),
322-
)
313+
await Promise.all(
314+
files.map(async (blobFilePath) => {
315+
const { dir: key } = parse(blobFilePath)
316+
const metaFile = join(pluginContext.blobDir, key, `blob.meta.json`)
317+
const metadata = await readFile(metaFile, 'utf-8')
318+
.then((meta) => JSON.parse(meta))
319+
.catch(() => ({}))
320+
await ctx.blobStore.set(
321+
key,
322+
await readFile(join(pluginContext.blobDir, blobFilePath), 'utf-8'),
323+
{
324+
metadata,
325+
},
326+
)
327+
}),
328+
)
329+
} else {
330+
const files = await glob('**/*', {
331+
dot: true,
332+
cwd: pluginContext.blobDir,
333+
})
334+
335+
const keys = files.filter((file) => !basename(file).startsWith('$'))
336+
await Promise.all(
337+
keys.map(async (key) => {
338+
const { dir, base } = parse(key)
339+
const metaFile = join(pluginContext.blobDir, dir, `$${base}.json`)
340+
const metadata = await readFile(metaFile, 'utf-8')
341+
.then((meta) => JSON.parse(meta))
342+
.catch(() => ({}))
343+
await ctx.blobStore.set(key, await readFile(join(pluginContext.blobDir, key), 'utf-8'), {
344+
metadata,
345+
})
346+
}),
347+
)
348+
}
323349
}
324350

325351
const DEFAULT_FLAGS = {

0 commit comments

Comments
 (0)