Spaces:
Running
Running
Download console/src/lib/ingestContract.test.mjs from Leon4gr45/brain: direct link, hf CLI and curl.
- Browser
- Download file 752 Bytes
-
https://huggingface.co/spaces/Leon4gr45/brain/resolve/main/console/src/lib/ingestContract.test.mjs
- Command line
-
hf download hf://spaces/Leon4gr45/brain/console/src/lib/ingestContract.test.mjs
-
curl -L -o ingestContract.test.mjs https://huggingface.co/spaces/Leon4gr45/brain/resolve/main/console/src/lib/ingestContract.test.mjs
752 Bytes
| import test from 'node:test'; | |
| import assert from 'node:assert/strict'; | |
| import { requireAcceptedTask } from './ingestContract.mjs'; | |
| for (const [status, payload] of [[422, {detail:'invalid'}], [500, {}], [200, {task_id:'valid'}], [202, {}], [202, {task_id:null}], [202, {task_id:'None'}], [202, {task_id:'null'}], [202, {task_id:''}]]) { | |
| test(`no task requests after ${status}/${JSON.stringify(payload)}`, () => { | |
| const requests = []; | |
| assert.throws(() => { | |
| const id = requireAcceptedTask(status, payload); | |
| requests.push(`/tasks/${id}`); | |
| }, /INGESTION_CONTRACT_ERROR/); | |
| assert.deepEqual(requests, []); | |
| }); | |
| } | |
| test('accepted task is pollable', () => assert.equal(requireAcceptedTask(202, {task_id:'task-123'}), 'task-123')); | |