Fix panic on scryfall error

This commit is contained in:
Artyom Belousov 2022-03-22 21:19:29 +03:00
parent ca0af01268
commit c6b0a150f1
2 changed files with 20 additions and 5 deletions

View file

@ -1,10 +1,12 @@
package cardsinfo
import (
"github.com/stretchr/testify/assert"
"gopkg.in/h2non/gock.v1"
"errors"
"net/http"
"testing"
"github.com/stretchr/testify/assert"
"gopkg.in/h2non/gock.v1"
)
func TestGetNameByCardId(t *testing.T) {
@ -64,3 +66,12 @@ func TestGetOriginalName_DoubleSide(t *testing.T) {
name := f.GetOriginalName("card")
assert.Equal(t, "Legion's Landing | Adanto, the First Fort", name)
}
func TestGetOriginalName_Error(t *testing.T) {
defer gock.Off()
gock.New(scryfallUrl + "/cards/named?fuzzy=card").ReplyError(errors.New("internal server error"))
f := &Fetcher{}
name := f.GetOriginalName("card")
assert.Equal(t, "", name)
}