mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
Tests: cover shared Telegram sent message cache
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { Bot } from "grammy";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { importFreshModule } from "../../test/helpers/import-fresh.js";
|
||||
import {
|
||||
getTelegramSendTestMocks,
|
||||
importTelegramSendModule,
|
||||
@@ -88,6 +89,29 @@ describe("sent-message-cache", () => {
|
||||
clearSentMessageCache();
|
||||
expect(wasSentByBot(123, 1)).toBe(false);
|
||||
});
|
||||
|
||||
it("shares sent-message state across distinct module instances", async () => {
|
||||
const cacheA = await importFreshModule<typeof import("./sent-message-cache.js")>(
|
||||
import.meta.url,
|
||||
"./sent-message-cache.js?scope=shared-a",
|
||||
);
|
||||
const cacheB = await importFreshModule<typeof import("./sent-message-cache.js")>(
|
||||
import.meta.url,
|
||||
"./sent-message-cache.js?scope=shared-b",
|
||||
);
|
||||
|
||||
cacheA.clearSentMessageCache();
|
||||
|
||||
try {
|
||||
cacheA.recordSentMessage(123, 1);
|
||||
expect(cacheB.wasSentByBot(123, 1)).toBe(true);
|
||||
|
||||
cacheB.clearSentMessageCache();
|
||||
expect(cacheA.wasSentByBot(123, 1)).toBe(false);
|
||||
} finally {
|
||||
cacheA.clearSentMessageCache();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildInlineKeyboard", () => {
|
||||
|
||||
Reference in New Issue
Block a user