You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
819 B

  1. package priceupdater
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/assert"
  5. )
  6. func TestCon(t *testing.T) {
  7. config := ConfigPriceUpdater{
  8. RecommendedFee: 1,
  9. RecommendedCreateAccountFee: 1,
  10. TokensList: []string{"ETH", "NEC"},
  11. APIURL: "https://api-pub.bitfinex.com/v2/",
  12. }
  13. pud := NewPriceUpdater(config)
  14. err := pud.UpdatePrices()
  15. assert.Equal(t, err, nil)
  16. info, _ := pud.Get("ETH")
  17. assert.NotZero(t, info.Value)
  18. info2, _ := pud.Get("NEC")
  19. assert.NotZero(t, info2.Value)
  20. info3, err := pud.Get("INVENTED")
  21. if assert.Error(t, err) {
  22. assert.Equal(t, ErrSymbolDoesNotExistInDatabase, err)
  23. }
  24. assert.Equal(t, info3.Value, float64(0))
  25. prices := pud.GetPrices()
  26. assert.Equal(t, prices["ETH"], info)
  27. assert.Equal(t, prices["NEC"], info2)
  28. }