fix: parse qa credential integer env strictly · openclaw/openclaw@19d1c21
steipete
·
2026-05-29
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { parseQaCredentialPositiveIntegerEnv } from "./qa-credentials-common.runtime.js"; |
| 3 | + |
| 4 | +describe("qa credential common runtime", () => { |
| 5 | +it("parses positive integer env values strictly", () => { |
| 6 | +expect( |
| 7 | +parseQaCredentialPositiveIntegerEnv({ |
| 8 | +env: { TEST_LIMIT: "42" }, |
| 9 | +fallback: 10, |
| 10 | +key: "TEST_LIMIT", |
| 11 | +}), |
| 12 | +).toBe(42); |
| 13 | +expect( |
| 14 | +parseQaCredentialPositiveIntegerEnv({ |
| 15 | +env: {}, |
| 16 | +fallback: 10, |
| 17 | +key: "TEST_LIMIT", |
| 18 | +}), |
| 19 | +).toBe(10); |
| 20 | + |
| 21 | +for (const value of ["0x10", "1e3", "4.5"]) { |
| 22 | +expect(() => |
| 23 | +parseQaCredentialPositiveIntegerEnv({ |
| 24 | +env: { TEST_LIMIT: value }, |
| 25 | +fallback: 10, |
| 26 | +key: "TEST_LIMIT", |
| 27 | +}), |
| 28 | +).toThrow("TEST_LIMIT must be a positive integer."); |
| 29 | +} |
| 30 | +}); |
| 31 | +}); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。