Files
Memoh/internal/channel/adapters/wecom/callback_cache_test.go
T
BBQ bc47655309 fix(wecom): align adapter with channel stream behavior
Migrate the imported WeCom adapter to current channel interfaces and stabilize stream delivery by preventing heartbeat/reply ACK timeout regressions and post-final overwrite updates.
2026-03-11 02:14:00 +08:00

30 lines
641 B
Go

package wecom
import (
"testing"
"time"
)
func TestCallbackContextCache_PutGet(t *testing.T) {
cache := newCallbackContextCache(1 * time.Hour)
cache.Put("m1", callbackContext{ReqID: "r1"})
got, ok := cache.Get("m1")
if !ok {
t.Fatal("expected cache hit")
}
if got.ReqID != "r1" {
t.Fatalf("unexpected req id: %q", got.ReqID)
}
}
func TestCallbackContextCache_Expires(t *testing.T) {
cache := newCallbackContextCache(1 * time.Second)
cache.Put("m1", callbackContext{
ReqID: "r1",
CreatedAt: time.Now().Add(-2 * time.Second),
})
if _, ok := cache.Get("m1"); ok {
t.Fatal("expected cache miss due to expiry")
}
}