31 lines
760 B
Go
31 lines
760 B
Go
package model
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"spark-server/internal/module/message/entity"
|
|
)
|
|
|
|
func TestTableOf(t *testing.T) {
|
|
if tableOf(entity.KindGroup) != tableGroupMessage {
|
|
t.Fatal("group")
|
|
}
|
|
if tableOf(entity.KindPrivate) != tablePrivateMessage {
|
|
t.Fatal("private")
|
|
}
|
|
if tableOf(0) != tablePrivateMessage {
|
|
t.Fatal("default private")
|
|
}
|
|
}
|
|
|
|
func TestQueryKeyRows(t *testing.T) {
|
|
priv := PrivateMessage{messageRow: messageRow{ID: 1, SenderID: 2}, ReceiverID: 3}
|
|
if got := priv.entity(); got.ReceiverID != 3 || got.Kind != entity.KindPrivate {
|
|
t.Fatalf("%+v", got)
|
|
}
|
|
grp := GroupMessage{messageRow: messageRow{ID: 4, SenderID: 5}, GroupID: 9}
|
|
if got := grp.entity(); got.GroupID != 9 || got.Kind != entity.KindGroup {
|
|
t.Fatalf("%+v", got)
|
|
}
|
|
}
|