mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-27 01:53:19 +01:00
test: expand channelserver coverage from 20% to 25%
Add tests for: - Discord handlers (getPlayerSlice, getCharacterList) - House handlers (boxToBytes, HouseData, Title structs) - Mail struct tests - Mercenary handlers (Partner, HunterNavi structs) - Shop/Gacha handlers (writeShopItems, ShopItem, Gacha structs) - Additional handler coverage for guild, tower, and simple handlers - Stage handler tests for binary operations and enumeration - Channel server tests for BroadcastMHF and session management
This commit is contained in:
@@ -295,3 +295,49 @@ func TestGenerateDivaTimestamps_Debug(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateDivaTimestamps_Debug_StartGreaterThan3(t *testing.T) {
|
||||
// Test debug mode with start > 3 (falls through to non-debug path)
|
||||
server := createMockServer()
|
||||
session := createMockSession(1, server)
|
||||
|
||||
// With debug=true but start > 3, should fall through to non-debug path
|
||||
// This will try to access DB which will panic, so we catch it
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
t.Log("Expected panic due to nil database in test")
|
||||
}
|
||||
}()
|
||||
|
||||
timestamps := generateDivaTimestamps(session, 100, true)
|
||||
if len(timestamps) != 6 {
|
||||
t.Errorf("Expected 6 timestamps, got %d", len(timestamps))
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateDivaTimestamps_NonDebug_WithValidStart(t *testing.T) {
|
||||
// Test non-debug mode with valid start timestamp (not expired)
|
||||
server := createMockServer()
|
||||
session := createMockSession(1, server)
|
||||
|
||||
// Use a start time in the future (won't trigger cleanup)
|
||||
futureStart := uint32(TimeAdjusted().Unix() + 1000000) // Far in the future
|
||||
|
||||
timestamps := generateDivaTimestamps(session, futureStart, false)
|
||||
if len(timestamps) != 6 {
|
||||
t.Errorf("Expected 6 timestamps, got %d", len(timestamps))
|
||||
}
|
||||
|
||||
// Verify first timestamp matches start
|
||||
if timestamps[0] != futureStart {
|
||||
t.Errorf("First timestamp should match start, got %d want %d", timestamps[0], futureStart)
|
||||
}
|
||||
|
||||
// Verify timestamp intervals
|
||||
if timestamps[1] != timestamps[0]+601200 {
|
||||
t.Error("Second timestamp should be start + 601200")
|
||||
}
|
||||
if timestamps[2] != timestamps[1]+3900 {
|
||||
t.Error("Third timestamp should be second + 3900")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user