fix unread cache invalidation for forwarded messages

This commit is contained in:
richjohnrambo
2026-09-24 16:37:05 +08:00
parent f952249dc3
commit d41956019a
2 changed files with 47 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
package store
import "testing"
func TestSubscriptionUpdateAffectsUnread(t *testing.T) {
tests := []struct {
name string
update map[string]any
want bool
}{
{name: "read seq", update: map[string]any{"ReadSeqId": int64(12)}, want: true},
{name: "delete marker", update: map[string]any{"DelId": 4}, want: true},
{name: "want mode", update: map[string]any{"ModeWant": 1}, want: true},
{name: "given mode", update: map[string]any{"ModeGiven": 1}, want: true},
{name: "deleted", update: map[string]any{"DeletedAt": "now"}, want: true},
{name: "recv only", update: map[string]any{"RecvSeqId": int64(12)}, want: false},
{name: "private only", update: map[string]any{"Private": map[string]any{"mute": true}}, want: false},
{name: "empty", update: map[string]any{}, want: false},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
if got := subscriptionUpdateAffectsUnread(tc.update); got != tc.want {
t.Fatalf("subscriptionUpdateAffectsUnread() = %v, want %v", got, tc.want)
}
})
}
}