55 lines
2.0 KiB
Go
55 lines
2.0 KiB
Go
package logic
|
|
|
|
import (
|
|
"testing"
|
|
|
|
msgentity "spark-server/internal/module/message/entity"
|
|
"spark-server/internal/module/meta/entity"
|
|
"spark-server/internal/pkg/i18n"
|
|
"spark-server/internal/transport/tcp/protocol"
|
|
)
|
|
|
|
func TestCatalogValuesMatchEntity(t *testing.T) {
|
|
c := Catalog(i18n.ZhCN)
|
|
if len(c.Gender) != 3 || c.Gender[1].Value != 1 || c.Gender[1].Name != "male" || c.Gender[1].Label != "男" {
|
|
t.Fatalf("gender %+v", c.Gender)
|
|
}
|
|
if len(c.MessageType) != 9 || c.MessageType[0].Value != int(msgentity.TypeText) || c.MessageType[8].Value != int(msgentity.TypeSystem) {
|
|
t.Fatalf("message_type %+v", c.MessageType)
|
|
}
|
|
if c.FriendRequestStatus[0].Value != 1 || c.FriendRequestStatus[1].Value != 2 {
|
|
t.Fatalf("friend_request_status %+v", c.FriendRequestStatus)
|
|
}
|
|
if c.TCPCommand[0].Value != int(protocol.CmdAuth) || c.TCPCommand[len(c.TCPCommand)-1].Value != int(protocol.CmdDeleteMessage) {
|
|
t.Fatalf("tcp_command %+v", c.TCPCommand)
|
|
}
|
|
if c.EnvelopeCode[0].Value != "0" || c.Language[0].Value != "zh-CN" {
|
|
t.Fatalf("wire %+v %+v", c.EnvelopeCode[0], c.Language)
|
|
}
|
|
if len(c.UploadPurpose) < 10 {
|
|
t.Fatalf("upload_purpose %+v", c.UploadPurpose)
|
|
}
|
|
if c.MomentKind[0].Value != 1 || c.MomentVisibility[2].Name != "include" {
|
|
t.Fatalf("moment %+v %+v", c.MomentKind, c.MomentVisibility)
|
|
}
|
|
en := Catalog(i18n.En)
|
|
if en.Gender[1].Label != "Male" || en.MessageType[0].Label != "Text" {
|
|
t.Fatalf("en labels %+v %+v", en.Gender, en.MessageType)
|
|
}
|
|
for _, items := range [][]entity.Item{
|
|
c.Gender, c.UserStatus, c.ConversationType, c.MessageKind, c.MessageType, c.MessageStatus,
|
|
c.RelationKind, c.FriendRequestStatus, c.FriendSource, c.ReportReason, c.GroupStatus, c.GroupRole,
|
|
c.MailboxEventType, c.TCPCommand, c.EnvelopeCode, c.DeviceType, c.Language, c.UploadPurpose, c.SystemKind,
|
|
c.MomentKind, c.MomentVisibility, c.MomentStatus, c.MomentNoticeKind, c.MomentVisibleDays,
|
|
} {
|
|
if len(items) == 0 {
|
|
t.Fatal("empty set")
|
|
}
|
|
for _, it := range items {
|
|
if it.Name == "" || it.Label == "" || it.Value == nil {
|
|
t.Fatalf("item %+v", it)
|
|
}
|
|
}
|
|
}
|
|
}
|