diff --git a/mlp/booster_test.go b/mlp/booster_test.go index 25b1a0b..6e44a8d 100644 --- a/mlp/booster_test.go +++ b/mlp/booster_test.go @@ -1,7 +1,6 @@ package mlp_test import ( - "fmt" "testing" "git.fromouter.space/mcg/draft" @@ -57,7 +56,7 @@ func TestAlternates(t *testing.T) { } } if prurfound { - fmt.Printf("PR Ultra Rare found after %d packs\n", i) + t.Logf("PR Ultra Rare found after %d packs\n", i) break } } @@ -78,7 +77,7 @@ func TestAlternates(t *testing.T) { } } if cnurfound { - fmt.Printf("CN Ultra Rare found after %d packs\n", i) + t.Logf("CN Ultra Rare found after %d packs\n", i) break } } @@ -92,7 +91,7 @@ func TestAlternates(t *testing.T) { pack := draft.MakePack(eoSet) // Check for royal rares if pack[6].ID == "eo207/rr1" || pack[6].ID == "eo208/rr2" { - fmt.Printf("EO Royal Rare found after %d packs\n", i) + t.Logf("EO Royal Rare found after %d packs\n", i) eorrfound = true break } diff --git a/mlp/i8pcube_test.go b/mlp/i8pcube_test.go index a28e477..6d995af 100644 --- a/mlp/i8pcube_test.go +++ b/mlp/i8pcube_test.go @@ -1,7 +1,6 @@ package mlp_test import ( - "fmt" "testing" "git.fromouter.space/mcg/draft" @@ -38,9 +37,9 @@ func TestDraftI8PCube(t *testing.T) { t.Errorf("Expected 2 cards in pack 3 but got %d", len(pack3)) } - fmt.Printf("Cards in pack1: %s\n", pack1) - fmt.Printf("Cards in pack2: %s\n", pack2) - fmt.Printf("Cards in pack3: %s\n", pack3) + t.Logf("Cards in pack1: %s\n", pack1) + t.Logf("Cards in pack2: %s\n", pack2) + t.Logf("Cards in pack3: %s\n", pack3) } // TestDryCube tries drying up the cube to make the "OtherProvider" not able to pick a card diff --git a/mlp/set_test.go b/mlp/set_test.go index 68a46d0..12dd6aa 100644 --- a/mlp/set_test.go +++ b/mlp/set_test.go @@ -1,7 +1,6 @@ package mlp_test import ( - "fmt" "testing" "git.fromouter.space/mcg/draft" @@ -27,8 +26,8 @@ func TestSet(t *testing.T) { t.Errorf("Expected 12 cards in pack 2 but got %d", len(pack2)) } - fmt.Printf("Cards in pack 1: %s\n", pack1) - fmt.Printf("Cards in pack 2: %s\n", pack2) + t.Logf("Cards in pack 1: %s\n", pack1) + t.Logf("Cards in pack 2: %s\n", pack2) } // TestWrongSet tries to fetch a set that doesn't exist diff --git a/set_test.go b/set_test.go index 3a43c52..fe2f099 100644 --- a/set_test.go +++ b/set_test.go @@ -8,16 +8,27 @@ import ( "git.fromouter.space/mcg/draft" ) +const PACKSIZE = 5 + +// Test set that can be used by tests that don't need special features (like alternates) +var testSet = &draft.GenericSet{ + Cards: []draft.Card{{ID: "a"}, {ID: "b"}, {ID: "c"}}, + PackSize: PACKSIZE, +} + +// Test cube that can be used by tests that don't need special features +var testCube = &draft.GenericCube{ + Cards: []draft.Card{ + {ID: "a"}, {ID: "b"}, {ID: "c"}, {ID: "d"}, {ID: "e"}, + {ID: "f"}, {ID: "g"}, {ID: "h"}, {ID: "i"}, + }, + PackSize: PACKSIZE, +} + // TestSetRepeatable makes sure that a set can generate more cards than it contains func TestSetRepeatable(t *testing.T) { - const PACKSIZE = 5 - s := &draft.GenericSet{ - Cards: []draft.Card{{ID: "a"}, {ID: "b"}, {ID: "c"}}, - PackSize: PACKSIZE, - } - // Create a pack - pack := draft.MakePack(s) + pack := draft.MakePack(testSet) if len(pack) < PACKSIZE { t.Errorf("Pack expected to contain %d cards, contains %d", PACKSIZE, len(pack)) @@ -77,17 +88,8 @@ func TestAlternateProviders(t *testing.T) { // TestCubeOverflow makes sure cubes stop providing cards as they are exhausted instead of going out of bound func TestCubeOverflow(t *testing.T) { - const PACKSIZE = 5 - c := &draft.GenericCube{ - Cards: []draft.Card{ - {ID: "a"}, {ID: "b"}, {ID: "c"}, {ID: "d"}, {ID: "e"}, - {ID: "f"}, {ID: "g"}, {ID: "h"}, {ID: "i"}, - }, - PackSize: PACKSIZE, - } - - pack1 := draft.MakePack(c) - pack2 := draft.MakePack(c) + pack1 := draft.MakePack(testCube) + pack2 := draft.MakePack(testCube) // Pack 2 can only contain 4 cards, as there are not enough cards to fill it if len(pack2) >= PACKSIZE {