diff --git a/db_test.go b/db_test.go index 23d5c41..917eb12 100644 --- a/db_test.go +++ b/db_test.go @@ -104,6 +104,30 @@ func TestQueryFitsDroneFilterHasCooccurringModules(t *testing.T) { assert.InDelta(t, 100.0, mod.Percentage, 0.01) } +func TestQueryFitsModuleFilterKeepsOtherModulesAndSlots(t *testing.T) { + dbi, err := GetDB() + require.NoError(t, err) + db := dbi.(*DBWrapper) + + resetModuleSlotCache(t) + + shipID := int64(32872) + moduleID := int64(16433) + + stats, err := db.QueryFits(QueryParams{Ship: shipID, Modules: []int64{moduleID}}) + require.NoError(t, err) + require.Greater(t, stats.TotalKillmails, int64(0)) + + mod := moduleStatsFor(stats, moduleID) + require.NotNil(t, mod) + assert.Equal(t, stats.TotalKillmails, mod.Count) + assert.InDelta(t, 100.0, mod.Percentage, 0.01) + + assert.Greater(t, len(stats.HighSlotModules), 1, "other high-slot modules should remain") + otherSlots := len(stats.MidSlotModules) + len(stats.LowSlotModules) + len(stats.Rigs) + len(stats.Drones) + assert.Greater(t, otherSlots, 0, "other slot categories should remain populated") +} + func pickTopSystemID(stats *FitStatistics) int64 { var bestID int64 var bestCount int64