Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
import { describe, it } from "node:test";
import assert from "node:assert/strict";
import { getStreak } from "../../../src/lib/gamification/streaks";
import { getDbInstance } from "../../../src/lib/db/core";
describe("stored streak counters", () => {
it("never read back negative or fractional", async () => {
getDbInstance()
.prepare("INSERT OR REPLACE INTO key_value (namespace, key, value) VALUES (?, ?, ?)")
.run(
"gamification:streaks",
"bad-counters-key",
JSON.stringify({
currentStreak: -5,
longestStreak: 2.5,
lastActiveDate: "2000-01-01",
streakStartDate: "2000-01-01",
})
);
const streak = await getStreak("bad-counters-key");
assert.equal(streak.currentStreak, 0);
assert.equal(streak.longestStreak, 2);
});
});