62 lines
1.4 KiB
Go
62 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
)
|
|
|
|
func TestKillmailIDsEndpoint(t *testing.T) {
|
|
db, err := GetDB()
|
|
if err != nil {
|
|
t.Fatalf("Failed to get DB: %v", err)
|
|
}
|
|
|
|
ctx := context.Background()
|
|
filters := AnalyticsFilters{
|
|
VictimShipTypeID: []int32{24692},
|
|
HasModule: &ModuleFilter{
|
|
ModuleID: 26914,
|
|
},
|
|
}
|
|
|
|
results, err := db.QueryKillmailIDs(ctx, filters, 100, 0)
|
|
if err != nil {
|
|
t.Fatalf("QueryKillmailIDs failed: %v", err)
|
|
}
|
|
|
|
if len(results) == 0 {
|
|
t.Fatalf("Expected at least one killmail ID, got 0")
|
|
}
|
|
|
|
t.Logf("Successfully retrieved %d killmail IDs", len(results))
|
|
t.Logf("First killmail ID: %d", results[0])
|
|
}
|
|
|
|
func TestModuleFilterExcludesCargo(t *testing.T) {
|
|
db, err := GetDB()
|
|
if err != nil {
|
|
t.Fatalf("Failed to get DB: %v", err)
|
|
}
|
|
|
|
ctx := context.Background()
|
|
filters := AnalyticsFilters{
|
|
HasModule: &ModuleFilter{
|
|
ModuleID: 26914,
|
|
},
|
|
}
|
|
|
|
results, err := db.QueryKillmailIDs(ctx, filters, 10000, 0)
|
|
if err != nil {
|
|
t.Fatalf("QueryKillmailIDs failed: %v", err)
|
|
}
|
|
|
|
// Check that killmail 126799160 is NOT in the results (module 26914 is in cargo, not fitted)
|
|
for _, id := range results {
|
|
if id == 126799160 {
|
|
t.Fatalf("Killmail 126799160 should NOT be returned because module 26914 is in cargo, not fitted. Got %d killmails total.", len(results))
|
|
}
|
|
}
|
|
|
|
t.Logf("Successfully verified that killmail 126799160 is NOT in results (module in cargo). Returned %d killmails.", len(results))
|
|
}
|