package model import ( "testing" ) // TestFriend_TableName 校验 Friend 表名 func TestFriend_TableName(t *testing.T) { if got := (Friend{}).TableName(); got != "friends" { t.Errorf("Friend.TableName() = %q, want %q", got, "friends") } } // TestPlayerAttributes_TableName 校验 PlayerAttributes 表名 func TestPlayerAttributes_TableName(t *testing.T) { if got := (PlayerAttributes{}).TableName(); got != "player_attributes" { t.Errorf("PlayerAttributes.TableName() = %q, want %q", got, "player_attributes") } } // TestFriendsStatus_Values 校验好友状态枚举值 func TestFriendsStatus_Values(t *testing.T) { tests := []struct { got, want FriendsStatus }{ {FriendsStatusPending, FriendsStatus("pending")}, {FriendsStatusAccepted, FriendsStatus("accepted")}, {FriendsStatusBlocked, FriendsStatus("blocked")}, } for _, tt := range tests { if tt.got != tt.want { t.Errorf("got %q, want %q", tt.got, tt.want) } } } // TestDefaultPlayerAttributes 校验默认偏好 func TestDefaultPlayerAttributes(t *testing.T) { d := DefaultPlayerAttributes("abc") if d.ProfileUUID != "abc" { t.Errorf("ProfileUUID = %q, want %q", d.ProfileUUID, "abc") } if !d.FriendsEnabled || !d.AcceptInvites || !d.ProfanityFilterOn { t.Errorf("默认偏好应为全部启用: %+v", d) } if d.TextCommunication != "ENABLED" { t.Errorf("TextCommunication = %q, want ENABLED", d.TextCommunication) } }