Example #1
0
func TestRace(t *testing.T) {
	api := hs.NewHsAPI("tntkXJyM7EmshBgQYsXtCHHEX8Izp1uHrN1jsnTpw7tNCxEZIN")
	api.Debug = true
	config := hs.NewCardsByRace(hs.Dragon)
	config.Collectible = true
	resp, err := api.CardsByRace(config)
	assert.NotEmpty(t, resp, "Empty Response")
	assert.NoError(t, err, "An error ocurred while testing Search")
	assert.NotEqual(t, 0, len(resp), "obtained no cards ")
	assert.Equal(t, resp[0].CardID, "BRM_004", "Wrong card fetched")
}
Example #2
0
func TestErrors(t *testing.T) {
	api := hs.NewHsAPI("tntkXJyM7EmshBgQYsXtCHHIzp1jsnTpw7tNCxEZIN")
	api.Debug = true

	//Type
	config := hs.NewCardsByType(hs.Weapon)
	config.Collectible = true
	resp, err := api.CardsByType(config)
	assert.Empty(t, resp, "Empty Response")
	assert.Error(t, err, "An error ocurred while testing Errors")

	//Race
	config1 := hs.NewCardsByRace(hs.Dragon)
	config1.Collectible = true
	resp1, err1 := api.CardsByRace(config1)
	assert.Empty(t, resp1, "Empty Response")
	assert.Error(t, err1, "An error ocurred while testing Errors")

	//Quality
	config2 := hs.NewCardsByQuality(hs.Legendary)
	config2.Collectible = true
	resp2, err2 := api.CardsByQuality(config2)
	assert.Empty(t, resp2, "Empty Response")
	assert.Error(t, err2, "An error ocurred while testing Errors")

	//Ifo
	config3 := hs.NewInfo()
	config3.Locale = hs.EsES
	resp3 := api.Info(config3)
	assert.NotEmpty(t, resp3, "Empty Response")

	//GetCard
	config4 := hs.NewGetCard("EX1_572")
	config4.Collectible = true
	resp4, err4 := api.GetCard(config4)
	assert.Empty(t, resp4, "Empty Response")
	assert.Error(t, err4, "An error ocurred while testing Errors")

	//AllCards
	config5 := hs.NewAllCards()
	config5.Collectible = true
	config5.Attack = 5
	config5.Durability = 5
	config5.Cost = 5
	resp5, err5 := api.AllCards(config5)
	assert.NotEmpty(t, resp5, "Empty Response")
	assert.Error(t, err5, "An error ocurred while testing Errors")

	//Cardbacks
	config6 := hs.NewCardBacks()
	config6.Locale = hs.EsES
	resp6, err6 := api.CardBacks(config6)
	assert.Empty(t, resp6, "Empty Response")
	assert.Error(t, err6, "An error ocurred while testing Errors")

	//CardSearch
	config7 := hs.NewCardSearch("tirion fordring")
	config7.Collectible = true
	resp7, err7 := api.Search(config7)
	assert.Empty(t, resp7, "Empty Response")
	assert.Error(t, err7, "An error ocurred while testing Errors")

	//By Set
	config8 := hs.NewCardsBySet(hs.TheGrandTournament)
	config8.Collectible = true
	resp8, err8 := api.CardsBySet(config8)
	assert.Empty(t, resp8, "Empty Response")
	assert.Error(t, err8, "An error ocurred while testing Errors")

	//By Class
	config9 := hs.NewCardsByClass(hs.Warlock)
	resp9, err9 := api.CardsByClass(config9)
	assert.Empty(t, resp9, "Empty Response")
	assert.Error(t, err9, "An error ocurred while testing Errors")

	//By Faction
	config10 := hs.NewCardsByFaction(hs.Horde)
	config10.Collectible = true
	resp10, err10 := api.CardsByFaction(config10)
	assert.Empty(t, resp10, "Empty Response")
	assert.Error(t, err10, "An error ocurred while testing Errors")

	//CardImg
	config11 := hs.NewCardImage("EX1383")
	config11.Gold = true
	_, err11 := api.CardImage(config11)
	assert.Error(t, err11, "An error ocurred while testing Errors")
}