@@ -47,7 +47,6 @@ vi.mock("openclaw/plugin-sdk/runtime-env", async () => {
4747} ) ;
4848
4949let resetDiscordChannelInfoCacheForTest : typeof import ( "./message-utils.js" ) . resetDiscordChannelInfoCacheForTest ;
50- let DISCORD_CHANNEL_INFO_CACHE_MAX_ENTRIES : typeof import ( "./message-utils.js" ) . DISCORD_CHANNEL_INFO_CACHE_MAX_ENTRIES ;
5150let resolveDiscordChannelInfo : typeof import ( "./message-utils.js" ) . resolveDiscordChannelInfo ;
5251let resolveDiscordMessageChannelId : typeof import ( "./message-utils.js" ) . resolveDiscordMessageChannelId ;
5352let resolveDiscordMessageText : typeof import ( "./message-utils.js" ) . resolveDiscordMessageText ;
@@ -57,7 +56,6 @@ let resolveReferencedReplyMediaList: typeof import("./message-utils.js").resolve
5756
5857beforeAll ( async ( ) => {
5958 ( {
60- DISCORD_CHANNEL_INFO_CACHE_MAX_ENTRIES ,
6159 resetDiscordChannelInfoCacheForTest,
6260 resolveDiscordChannelInfo,
6361 resolveDiscordMessageChannelId,
@@ -1228,23 +1226,21 @@ describe("resolveDiscordChannelInfo", () => {
12281226 } ) ;
12291227
12301228 it ( "caps cached channel info entries" , async ( ) => {
1229+ const cacheEntryLimit = 1000 ;
12311230 const fetchChannel = vi . fn ( async ( channelId : string ) => ( {
12321231 type : ChannelType . GuildText ,
12331232 name : `name-${ channelId } ` ,
12341233 } ) ) ;
12351234 const client = { fetchChannel } as unknown as Client ;
12361235
1237- for ( let index = 0 ; index <= DISCORD_CHANNEL_INFO_CACHE_MAX_ENTRIES ; index += 1 ) {
1236+ for ( let index = 0 ; index <= cacheEntryLimit ; index += 1 ) {
12381237 await resolveDiscordChannelInfo ( client , `channel-${ index } ` ) ;
12391238 }
12401239 await resolveDiscordChannelInfo ( client , "channel-0" ) ;
1241- await resolveDiscordChannelInfo ( client , `channel-${ DISCORD_CHANNEL_INFO_CACHE_MAX_ENTRIES } ` ) ;
1240+ await resolveDiscordChannelInfo ( client , `channel-${ cacheEntryLimit } ` ) ;
12421241
1243- expect ( fetchChannel ) . toHaveBeenCalledTimes ( DISCORD_CHANNEL_INFO_CACHE_MAX_ENTRIES + 2 ) ;
1244- expect ( fetchChannel ) . toHaveBeenNthCalledWith (
1245- DISCORD_CHANNEL_INFO_CACHE_MAX_ENTRIES + 2 ,
1246- "channel-0" ,
1247- ) ;
1242+ expect ( fetchChannel ) . toHaveBeenCalledTimes ( cacheEntryLimit + 2 ) ;
1243+ expect ( fetchChannel ) . toHaveBeenNthCalledWith ( cacheEntryLimit + 2 , "channel-0" ) ;
12481244 } ) ;
12491245
12501246 it ( "negative-caches missing channels" , async ( ) => {
0 commit comments