You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.0 KiB
Go

package model
import "testing"
func TestSetGearCatalog_FillsMissingSlotsFromDefaults(t *testing.T) {
originalCatalog := append([]GearFamily(nil), GearCatalog...)
originalBySlot := make(map[EquipmentSlot][]GearFamily, len(gearBySlot))
for slot, families := range gearBySlot {
originalBySlot[slot] = append([]GearFamily(nil), families...)
}
defer func() {
GearCatalog = originalCatalog
gearBySlot = originalBySlot
}()
dbOnlyMainHand := []GearFamily{
{
Slot: SlotMainHand,
FormID: "gear.form.main_hand.test",
Name: "Test Blade",
BasePrimary: 10,
StatType: "attack",
},
}
SetGearCatalog(dbOnlyMainHand)
if got := len(gearBySlot[SlotMainHand]); got != 1 {
t.Fatalf("expected main hand to keep only db families, got %d", got)
}
if gearBySlot[SlotMainHand][0].Name != "Test Blade" {
t.Fatalf("expected db main hand family to be used, got %q", gearBySlot[SlotMainHand][0].Name)
}
if got := len(gearBySlot[SlotHead]); got == 0 {
t.Fatalf("expected missing slot to be filled from defaults, got %d", got)
}
}