26 lines
699 B
Go
26 lines
699 B
Go
package mysql
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"hyapp/pkg/appcode"
|
|
)
|
|
|
|
func TestGetRoomMetaByShortIDReturnsCanonicalRoomID(t *testing.T) {
|
|
ctx := appcode.WithContext(context.Background(), appcode.Default)
|
|
repo := newCommandLogTestRepository(t, ctx)
|
|
insertCommandLogTestRoom(t, ctx, repo, "room-meta-short")
|
|
|
|
meta, exists, err := repo.GetRoomMetaByShortID(ctx, " room-meta-short-short ")
|
|
if err != nil {
|
|
t.Fatalf("get room meta by short id: %v", err)
|
|
}
|
|
if !exists {
|
|
t.Fatal("room short id should resolve existing room meta")
|
|
}
|
|
if meta.RoomID != "room-meta-short" || meta.RoomShortID != "room-meta-short-short" {
|
|
t.Fatalf("short id must return canonical room meta, got %+v", meta)
|
|
}
|
|
}
|