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:
Houmgaor
2026-02-26 23:41:44 +01:00
parent a68d76c55f
commit d0837e779c
53 changed files with 5922 additions and 6118 deletions

View File

@@ -190,6 +190,77 @@ func TestUpdateRights(t *testing.T) {
}
}
// Tests consolidated from handlers_coverage3_test.go
func TestStubHelpers(t *testing.T) {
server := createMockServer()
t.Run("stubEnumerateNoResults", func(t *testing.T) {
session := createMockSession(1, server)
stubEnumerateNoResults(session, 1)
select {
case p := <-session.sendPackets:
if len(p.data) == 0 {
t.Error("response should have data")
}
default:
t.Error("no response queued")
}
})
t.Run("doAckBufSucceed", func(t *testing.T) {
session := createMockSession(1, server)
doAckBufSucceed(session, 1, []byte{0x01, 0x02, 0x03})
select {
case p := <-session.sendPackets:
if len(p.data) == 0 {
t.Error("response should have data")
}
default:
t.Error("no response queued")
}
})
t.Run("doAckBufFail", func(t *testing.T) {
session := createMockSession(1, server)
doAckBufFail(session, 1, []byte{0x01, 0x02, 0x03})
select {
case p := <-session.sendPackets:
if len(p.data) == 0 {
t.Error("response should have data")
}
default:
t.Error("no response queued")
}
})
t.Run("doAckSimpleSucceed", func(t *testing.T) {
session := createMockSession(1, server)
doAckSimpleSucceed(session, 1, []byte{0x00, 0x00, 0x00, 0x00})
select {
case p := <-session.sendPackets:
if len(p.data) == 0 {
t.Error("response should have data")
}
default:
t.Error("no response queued")
}
})
t.Run("doAckSimpleFail", func(t *testing.T) {
session := createMockSession(1, server)
doAckSimpleFail(session, 1, []byte{0x00, 0x00, 0x00, 0x00})
select {
case p := <-session.sendPackets:
if len(p.data) == 0 {
t.Error("response should have data")
}
default:
t.Error("no response queued")
}
})
}
func TestUpdateRights_Error(t *testing.T) {
server := createMockServer()
userRepo := &mockUserRepoGacha{rightsErr: errors.New("db error")}