owpengram-server/internal/rpc/message_grouped_projection_test.go

39 lines
1.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package rpc
import (
"testing"
"github.com/gotd/td/tg"
"telesrv/internal/domain"
)
// TestMessageGroupedIDProjection 验证相册 grouped_id 投影到 tg.Message私聊+频道),
// 0 值不下发flag-optional非零下发。
func TestMessageGroupedIDProjection(t *testing.T) {
const groupedID = int64(880000000123)
priv := tgMessage(domain.Message{
ID: 5,
Peer: domain.Peer{Type: domain.PeerTypeUser, ID: 1002},
GroupedID: groupedID,
}).(*tg.Message)
if got, ok := priv.GetGroupedID(); !ok || got != groupedID {
t.Fatalf("private grouped_id = %d ok %v, want %d", got, ok, groupedID)
}
plain := tgMessage(domain.Message{ID: 6, Peer: domain.Peer{Type: domain.PeerTypeUser, ID: 1002}}).(*tg.Message)
if _, ok := plain.GetGroupedID(); ok {
t.Fatal("non-album private message must not carry grouped_id")
}
ch := tgChannelMessage(1001, domain.ChannelMessage{
ChannelID: 2000,
ID: 7,
From: domain.Peer{Type: domain.PeerTypeUser, ID: 1001},
GroupedID: groupedID,
}).(*tg.Message)
if got, ok := ch.GetGroupedID(); !ok || got != groupedID {
t.Fatalf("channel grouped_id = %d ok %v, want %d", got, ok, groupedID)
}
}