mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-26 17:43:21 +01:00
refactor(channelserver): consolidate tests into matching source test files
Move ~300 test functions from 21 catch-all files (handlers_core_test.go, handlers_coverage*_test.go, *_coverage_test.go) into the *_test.go file matching each handler's source file. This makes tests discoverable by convention: tests for handlers_guild.go live in handlers_guild_test.go. New files: handlers_guild_mission_test.go, sys_time_test.go. No test logic changed — pure file reorganization.
This commit is contained in:
@@ -120,6 +120,54 @@ func TestHandleMsgMhfCaravanRanking(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Tests consolidated from handlers_coverage3_test.go
|
||||
|
||||
func TestNonTrivialHandlers_CaravanGo(t *testing.T) {
|
||||
server := createMockServer()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
fn func(s *Session)
|
||||
}{
|
||||
{"handleMsgMhfGetRyoudama", func(s *Session) {
|
||||
handleMsgMhfGetRyoudama(s, &mhfpacket.MsgMhfGetRyoudama{AckHandle: 1})
|
||||
}},
|
||||
{"handleMsgMhfGetTinyBin", func(s *Session) {
|
||||
handleMsgMhfGetTinyBin(s, &mhfpacket.MsgMhfGetTinyBin{AckHandle: 1})
|
||||
}},
|
||||
{"handleMsgMhfPostTinyBin", func(s *Session) {
|
||||
handleMsgMhfPostTinyBin(s, &mhfpacket.MsgMhfPostTinyBin{AckHandle: 1})
|
||||
}},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
session := createMockSession(1, server)
|
||||
tt.fn(session)
|
||||
select {
|
||||
case p := <-session.sendPackets:
|
||||
if len(p.data) == 0 {
|
||||
t.Errorf("%s: response should have data", tt.name)
|
||||
}
|
||||
default:
|
||||
t.Errorf("%s: no response queued", tt.name)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestEmptyHandlers_MiscFiles_Caravan(t *testing.T) {
|
||||
server := createMockServer()
|
||||
session := createMockSession(1, server)
|
||||
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
t.Errorf("handleMsgMhfPostRyoudama panicked: %v", r)
|
||||
}
|
||||
}()
|
||||
handleMsgMhfPostRyoudama(session, nil)
|
||||
}
|
||||
|
||||
func TestHandleMsgMhfCaravanMyRank(t *testing.T) {
|
||||
server := createMockServer()
|
||||
session := createMockSession(1, server)
|
||||
|
||||
Reference in New Issue
Block a user