package mlp_test import ( "testing" "git.fromouter.space/mcg/draft/mlp" ) func TestLoadCardList(t *testing.T) { // Fetch two random cards cards, err := mlp.LoadCardList([]string{"ff3", "pr54"}, true) if err != nil { t.Fatalf("Error while fetching cards: %s", err.Error()) } // Check that fetched cards are the real deal if cards[0].Name != "Ocellus" { t.Fatalf("First card (ff3) is not Ocellus but %s", cards[0].Name) } if cards[1].Name != "Comet Tail" { t.Fatalf("Second card (pr54) is not Comet Tail but %s", cards[1].Name) } } func TestLoadCardListErrors(t *testing.T) { // Clean all loaded sets mlp.CleanSetCache() // Fetch a card from an inexistant set _, err := mlp.LoadCardList([]string{"E"}, true) if err == nil { t.Fatalf("LoadCardList succeeded fetching a card with an invalid ID") } else if err != mlp.ErrInvalidCardID { t.Fatalf("[E] Expected ErrInvalidCardID but got: %s", err.Error()) } // Fetch a card from an inexistant set _, err = mlp.LoadCardList([]string{"oof3"}, true) if err == nil { t.Fatalf("LoadCardList succeeded fetching a card from a non-existant set") } // Fetch an non-existant card in a real set _, err = mlp.LoadCardList([]string{"ff3000"}, true) if err == nil { t.Fatalf("LoadCardList succeeded fetching a non-existant card from a real set") } else if err != mlp.ErrCardNotFound { t.Fatalf("[ff3000] Expected ErrCardNotFound but got: %s", err.Error()) } // Try fetching from non-loaded sets _, err = mlp.LoadCardList([]string{"pr10"}, false) if err == nil { t.Fatalf("LoadCardList succeeded fetching from a set that wasn't loaded") } else if err != mlp.ErrSetNotLoaded { t.Fatalf("Expected ErrSetNotLoaded but got: %s", err.Error()) } }