Spaces:
Paused
Paused
ML Intern deploy
Deploy httpSMS gateway to Hugging Face Spaces (Docker SDK): nginx :7860 -> Go API :8000, Nuxt SPA, Android APK, bootstrap-mode entrypoint
83a59ca Download web/app/utils/errors.test.ts from red-kit/httpsms-gateway: direct link, hf CLI and curl.
- Browser
- Download file 1.22 kB
-
https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/main/web/app/utils/errors.test.ts
- Command line
-
hf download hf://spaces/red-kit/httpsms-gateway/web/app/utils/errors.test.ts
-
curl -L -o errors.test.ts https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/main/web/app/utils/errors.test.ts
1.22 kB
| import assert from 'node:assert/strict' | |
| import { test } from 'node:test' | |
| import { getErrorMessages } from './errors' | |
| const validationData = { | |
| messages_per_minute: [ | |
| 'The messages_per_minute field value can not be greater than 30', | |
| ], | |
| } | |
| test('formats fetch validation errors while retaining field keys', () => { | |
| const errors = getErrorMessages({ | |
| status: 422, | |
| data: { data: validationData }, | |
| response: new Response(null, { status: 422 }), | |
| }) | |
| assert.deepEqual(errors.get('messages_per_minute'), [ | |
| 'The messages per minute value can not be greater than 30', | |
| ]) | |
| }) | |
| test('still formats Axios validation errors', () => { | |
| const errors = getErrorMessages({ | |
| response: { status: 422, data: { data: validationData } }, | |
| }) | |
| assert.deepEqual(errors.get('messages_per_minute'), [ | |
| 'The messages per minute value can not be greater than 30', | |
| ]) | |
| }) | |
| test('does not turn non-validation failures into field errors', () => { | |
| for (const error of [ | |
| null, | |
| undefined, | |
| new Error('Network error'), | |
| { status: 500, data: { data: validationData } }, | |
| { status: 422, data: { message: 'Validation failed' } }, | |
| ]) { | |
| assert.equal(getErrorMessages(error).size(), 0) | |
| } | |
| }) | |