Redis -> YDB
This commit is contained in:
parent
1f4888069f
commit
a33680d527
21 changed files with 448 additions and 322 deletions
|
|
@ -1,5 +1,4 @@
|
|||
package cardsinfo
|
||||
|
||||
type Fetcher struct {
|
||||
Dict map[string]string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"gitlab.com/flygrounder/go-mtg-vk/internal/dicttranslate"
|
||||
)
|
||||
|
||||
const scryfallUrl = "https://api.scryfall.com"
|
||||
|
|
@ -23,9 +21,6 @@ func (f *Fetcher) GetNameByCardId(set string, number string) string {
|
|||
func (f *Fetcher) GetOriginalName(name string) string {
|
||||
path := scryfallUrl + "/cards/named?fuzzy=" + applyFilters(name)
|
||||
result := getCardByUrl(path)
|
||||
if result == "" && f.Dict != nil {
|
||||
result, _ = dicttranslate.Find(name, f.Dict, 5)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,21 +31,6 @@ func TestGetOriginalName_Scryfall(t *testing.T) {
|
|||
assert.Equal(t, "Result Card", name)
|
||||
}
|
||||
|
||||
func TestGetOriginalName_DictTwice(t *testing.T) {
|
||||
defer gock.Off()
|
||||
|
||||
gock.New(scryfallUrl + "/cards/named?fuzzy=card").Persist().Reply(http.StatusOK).JSON(card{})
|
||||
f := &Fetcher{
|
||||
Dict: map[string]string{
|
||||
"card": "Card",
|
||||
},
|
||||
}
|
||||
name := f.GetOriginalName("card")
|
||||
assert.Equal(t, "Card", name)
|
||||
name = f.GetOriginalName("card")
|
||||
assert.Equal(t, "Card", name)
|
||||
}
|
||||
|
||||
func TestGetOriginalName_BadJson(t *testing.T) {
|
||||
defer gock.Off()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue