65 lines
1.5 KiB
Go
65 lines
1.5 KiB
Go
|
package mlp_test
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"git.fromouter.space/mcg/draft/mlp"
|
||
|
)
|
||
|
|
||
|
// Tests a block packprovider
|
||
|
func TestBlockProvider(t *testing.T) {
|
||
|
// Clean all loaded sets
|
||
|
mlp.CleanSetCache()
|
||
|
|
||
|
// Load all needed sets
|
||
|
sets := []mlp.SetID{
|
||
|
mlp.SetPremiere,
|
||
|
mlp.SetCanterlotNights,
|
||
|
mlp.SetCrystalGames,
|
||
|
mlp.SetAbsoluteDiscord,
|
||
|
mlp.SetEquestrialOdysseys,
|
||
|
mlp.SetHighMagic,
|
||
|
mlp.SetMarksInTime,
|
||
|
mlp.SetDefendersOfEquestria,
|
||
|
mlp.SetSeaquestriaBeyond,
|
||
|
mlp.SetFriendsForever,
|
||
|
}
|
||
|
for _, setid := range sets {
|
||
|
_, err := mlp.LoadSetHTTP(setid)
|
||
|
if err != nil {
|
||
|
t.Fatalf("Could not load needed set: %s", err.Error())
|
||
|
}
|
||
|
}
|
||
|
|
||
|
PR, err := mlp.BlockPacks(mlp.BlockPremiere)
|
||
|
if err != nil {
|
||
|
t.Fatalf("Could not load sets for premiere block draft: %s", err.Error())
|
||
|
}
|
||
|
EO, err := mlp.BlockPacks(mlp.BlockOdyssey)
|
||
|
if err != nil {
|
||
|
t.Fatalf("Could not load sets for odyssey block draft: %s", err.Error())
|
||
|
}
|
||
|
DE, err := mlp.BlockPacks(mlp.BlockDefenders)
|
||
|
if err != nil {
|
||
|
t.Fatalf("Could not load sets for defenders block draft: %s", err.Error())
|
||
|
}
|
||
|
|
||
|
// Generate packs for each block
|
||
|
_ = PR()
|
||
|
_ = EO()
|
||
|
_ = DE()
|
||
|
}
|
||
|
|
||
|
// Tests trying to make a packprovider of a block that's not loaded
|
||
|
func TestBlockError(t *testing.T) {
|
||
|
// Clean all loaded sets
|
||
|
mlp.CleanSetCache()
|
||
|
_, err := mlp.BlockPacks(mlp.BlockPremiere)
|
||
|
if err == nil {
|
||
|
t.Fatal("Could somehow generate a packprovider even though the set shouldn't be loaded")
|
||
|
}
|
||
|
if err != mlp.ErrSetNotLoaded {
|
||
|
t.Fatalf("Got an error but it's not the right one: %s", err.Error())
|
||
|
}
|
||
|
}
|