diff --git a/packages/upload-client/test/helpers/receipts-server.js b/packages/upload-client/test/helpers/receipts-server.js index d16181690..cc74b77ba 100644 --- a/packages/upload-client/test/helpers/receipts-server.js +++ b/packages/upload-client/test/helpers/receipts-server.js @@ -52,16 +52,16 @@ const server = createServer(async (req, res) => { const taskCid = req.url?.split('/')[1] ?? '' if (taskCid === 'unavailable') { res.writeHead(404) - return res.end() + res.end() } else if (taskCid === 'failed') { const body = await generateReceipt((await randomCAR(128)).cid.toString()) res.writeHead(200) - return res.end(body) + res.end(body) + } else { + const body = await generateReceipt(taskCid) + res.writeHead(200) + res.end(body) } - - const body = await generateReceipt(taskCid) - res.writeHead(200) - res.end(body) }) server.listen(port, () => console.log(`Listening on :${port}`)) diff --git a/packages/upload-client/test/fixtures/workflow.car b/packages/w3up-client/test/fixtures/workflow.car similarity index 100% rename from packages/upload-client/test/fixtures/workflow.car rename to packages/w3up-client/test/fixtures/workflow.car diff --git a/packages/w3up-client/test/helpers/receipts-server.js b/packages/w3up-client/test/helpers/receipts-server.js index 0fa2fecc3..4664f9a0e 100644 --- a/packages/w3up-client/test/helpers/receipts-server.js +++ b/packages/w3up-client/test/helpers/receipts-server.js @@ -12,32 +12,23 @@ import { randomCAR } from './random.js' const port = process.env.PORT ?? 9201 const __dirname = path.dirname(fileURLToPath(import.meta.url)) const fixtureName = process.env.FIXTURE_NAME || 'workflow.car' +const fixtureContent = fs.readFileSync( + path.resolve(`${__dirname}`, '..', 'fixtures', fixtureName) +) const server = createServer(async (req, res) => { res.setHeader('Access-Control-Allow-Origin', '*') res.setHeader('Access-Control-Allow-Methods', '*') res.setHeader('Access-Control-Allow-Headers', '*') - const taskID = req.url?.split('/')[1] ?? '' - if (taskID === 'unavailable') { - res.writeHead(404) - return res.end() - } else if ( - taskID === 'bafyreibo6nqtvp67daj7dkmeb5c2n6bg5bunxdmxq3lghtp3pmjtzpzfma' + const taskCid = req.url?.split('/')[1] ?? '' + if ( + taskCid === 'bafyreibo6nqtvp67daj7dkmeb5c2n6bg5bunxdmxq3lghtp3pmjtzpzfma' ) { - return fs.readFile( - path.resolve(`${__dirname}`, '..', 'fixtures', fixtureName), - (error, content) => { - if (error) { - res.writeHead(500) - res.end() - } - res.writeHead(200, { - 'Content-disposition': 'attachment; filename=' + fixtureName, - }) - res.end(content) - } - ) + res.writeHead(200, { + 'Content-disposition': 'attachment; filename=' + fixtureName, + }) + return res.end(fixtureContent) } const issuer = await Signer.generate() @@ -58,7 +49,7 @@ const server = createServer(async (req, res) => { fx: { fork: [locationClaim], }, - ran: parseLink(taskID), + ran: parseLink(taskCid), result: { ok: { site: locationClaim.link(),