kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
pull/715/head
rodzic
817e726044
commit
9da4820e00
|
@ -19,7 +19,8 @@
|
|||
"scripts": {
|
||||
"test": "run-s test:*",
|
||||
"test:lint": "eslint .",
|
||||
"test:typecheck": "tsc --noEmit"
|
||||
"test:typecheck": "tsc --noEmit",
|
||||
"test:unit": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@agentic/platform-core": "workspace:*",
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`rateLimitSchema invalid 1`] = `
|
||||
[ZodError: [
|
||||
{
|
||||
"code": "too_small",
|
||||
"minimum": 1,
|
||||
"type": "string",
|
||||
"inclusive": true,
|
||||
"exact": false,
|
||||
"message": "String must contain at least 1 character(s)",
|
||||
"path": [
|
||||
"interval"
|
||||
]
|
||||
}
|
||||
]]
|
||||
`;
|
||||
|
||||
exports[`rateLimitSchema invalid 2`] = `
|
||||
[ZodError: [
|
||||
{
|
||||
"code": "custom",
|
||||
"message": "Invalid interval \\"--\\"",
|
||||
"path": [
|
||||
"interval",
|
||||
"interval"
|
||||
]
|
||||
}
|
||||
]]
|
||||
`;
|
||||
|
||||
exports[`rateLimitSchema invalid 3`] = `
|
||||
[ZodError: [
|
||||
{
|
||||
"code": "too_small",
|
||||
"minimum": 0,
|
||||
"type": "number",
|
||||
"inclusive": true,
|
||||
"exact": false,
|
||||
"message": "Number must be greater than or equal to 0",
|
||||
"path": [
|
||||
"maxPerInterval"
|
||||
]
|
||||
}
|
||||
]]
|
||||
`;
|
||||
|
||||
exports[`rateLimitSchema valid 1`] = `
|
||||
{
|
||||
"interval": 10,
|
||||
"maxPerInterval": 100,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`rateLimitSchema valid 2`] = `
|
||||
{
|
||||
"interval": 10,
|
||||
"maxPerInterval": 100,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`rateLimitSchema valid 3`] = `
|
||||
{
|
||||
"interval": 86400,
|
||||
"maxPerInterval": 1000,
|
||||
}
|
||||
`;
|
|
@ -0,0 +1,49 @@
|
|||
import { expect, test } from 'vitest'
|
||||
|
||||
import { rateLimitSchema } from './schemas'
|
||||
|
||||
test('rateLimitSchema valid', () => {
|
||||
expect(
|
||||
rateLimitSchema.parse({
|
||||
interval: 10,
|
||||
maxPerInterval: 100
|
||||
})
|
||||
).toMatchSnapshot()
|
||||
|
||||
expect(
|
||||
rateLimitSchema.parse({
|
||||
interval: '10s',
|
||||
maxPerInterval: 100
|
||||
})
|
||||
).toMatchSnapshot()
|
||||
|
||||
expect(
|
||||
rateLimitSchema.parse({
|
||||
interval: '1 day',
|
||||
maxPerInterval: 1000
|
||||
})
|
||||
).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('rateLimitSchema invalid', () => {
|
||||
expect(() =>
|
||||
rateLimitSchema.parse({
|
||||
interval: '',
|
||||
maxPerInterval: 5
|
||||
})
|
||||
).toThrowErrorMatchingSnapshot()
|
||||
|
||||
expect(() =>
|
||||
rateLimitSchema.parse({
|
||||
interval: '--',
|
||||
maxPerInterval: 10
|
||||
})
|
||||
).toThrowErrorMatchingSnapshot()
|
||||
|
||||
expect(() =>
|
||||
rateLimitSchema.parse({
|
||||
interval: '1 day',
|
||||
maxPerInterval: -1000
|
||||
})
|
||||
).toThrowErrorMatchingSnapshot()
|
||||
})
|
|
@ -59,6 +59,7 @@ export const rateLimitSchema = z
|
|||
*/
|
||||
maxPerInterval: z
|
||||
.number()
|
||||
.nonnegative()
|
||||
.describe('Maximum number of operations per interval (unitless).')
|
||||
})
|
||||
.openapi('RateLimit')
|
||||
|
|
Ładowanie…
Reference in New Issue