mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
bc47655309
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.
30 lines
641 B
Go
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")
|
|
}
|
|
}
|