Compare commits

...

2 commits

Author SHA1 Message Date
3184ce476a
We don't need this as a global
All checks were successful
continuous-integration/drone/push Build is passing
2019-06-28 22:45:39 +02:00
d2a2e4526b
Add LoadAllSets
All checks were successful
continuous-integration/drone/tag Build is passing
2019-06-28 22:35:47 +02:00
3 changed files with 33 additions and 3 deletions

View file

@ -41,3 +41,18 @@ const (
BlockOdyssey BlockID = "EO" // Odyssey block - EO/HM/MT BlockOdyssey BlockID = "EO" // Odyssey block - EO/HM/MT
BlockDefenders BlockID = "DE" // Defenders block - DE/SB/FF BlockDefenders BlockID = "DE" // Defenders block - DE/SB/FF
) )
var allSets = []SetID{
SetPremiere,
SetCanterlotNights,
SetRockNRave,
SetCelestialSolstice,
SetCrystalGames,
SetAbsoluteDiscord,
SetEquestrialOdysseys,
SetHighMagic,
SetMarksInTime,
SetDefendersOfEquestria,
SetSeaquestriaBeyond,
SetFriendsForever,
}

View file

@ -120,3 +120,14 @@ func LoadSetHTTP(id SetID) (*Set, error) {
return LoadSetBytes(id, data) return LoadSetBytes(id, data)
} }
// LoadAllSets just loads all sets from the web
func LoadAllSets() error {
for _, set := range allSets {
_, err := LoadSetHTTP(set)
if err != nil {
return err
}
}
return nil
}

View file

@ -75,6 +75,12 @@ func TestAllLoads(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("[LoadSetMemory] Could not load set: %s", err.Error()) t.Fatalf("[LoadSetMemory] Could not load set: %s", err.Error())
} }
// Load all remaining sets
err = mlp.LoadAllSets()
if err != nil {
t.Fatalf("[LoadAllSets] Could not load remaining sets: %s", err.Error())
}
} }
// TestNotLoadedErr tests that LoadSetMemory fails if set is not cached // TestNotLoadedErr tests that LoadSetMemory fails if set is not cached
@ -166,10 +172,8 @@ func TestMalformedJSONLoad(t *testing.T) {
} }
} }
var testServer *httptest.Server
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
switch req.URL.Path { switch req.URL.Path {
case "/nopenope.json": case "/nopenope.json":
// 404 // 404