test(m3): add Upstash read-tier rate limit HTTP test

Node test asserts 429 with Retry-After after 60 GET requests per IP.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Mauricio Barragan
2026-06-17 21:35:11 -06:00
parent 8c7127cfde
commit f6e8381c20
5 changed files with 99 additions and 3 deletions
+35
View File
@@ -0,0 +1,35 @@
import { existsSync, readFileSync } from "node:fs";
import { join } from "node:path";
/** Loads `.env.local` without overriding variables already set in the shell. */
export function loadEnvLocal(): void {
const file = join(process.cwd(), ".env.local");
if (!existsSync(file)) {
return;
}
for (const line of readFileSync(file, "utf8").split(/\r?\n/)) {
const trimmed = line.trim();
if (!trimmed || trimmed.startsWith("#")) {
continue;
}
const eq = trimmed.indexOf("=");
if (eq <= 0) {
continue;
}
const key = trimmed.slice(0, eq).trim();
let value = trimmed.slice(eq + 1).trim();
if (
(value.startsWith('"') && value.endsWith('"')) ||
(value.startsWith("'") && value.endsWith("'"))
) {
value = value.slice(1, -1);
}
if (process.env[key] === undefined) {
process.env[key] = value;
}
}
}