github.com/bitfinexcom/bitfinex-api-go@v0.0.0-20210608095005-9e0b26f200fb/pkg/models/fundinginfo/fundinginfo_test.go (about) 1 package fundinginfo_test 2 3 import ( 4 "testing" 5 6 "github.com/bitfinexcom/bitfinex-api-go/pkg/models/fundinginfo" 7 "github.com/stretchr/testify/assert" 8 "github.com/stretchr/testify/require" 9 ) 10 11 func TestNewFundingInfoFromRaw(t *testing.T) { 12 t.Run("invalid arguments", func(t *testing.T) { 13 payload := []interface{}{"sym"} 14 15 got, err := fundinginfo.FromRaw(payload) 16 require.NotNil(t, err) 17 require.Nil(t, got) 18 }) 19 20 t.Run("valid arguments", func(t *testing.T) { 21 payload := []interface{}{ 22 "sym", 23 "fUST", 24 []interface{}{ 25 0.0024, 26 0.0024, 27 1.9522164351851852, 28 1.4818560606060607, 29 }, 30 } 31 32 got, err := fundinginfo.FromRaw(payload) 33 require.Nil(t, err) 34 35 expected := &fundinginfo.FundingInfo{ 36 Symbol: "fUST", 37 YieldLoan: 0.0024, 38 YieldLend: 0.0024, 39 DurationLoan: 1.9522164351851852, 40 DurationLend: 1.4818560606060607, 41 } 42 assert.Equal(t, expected, got) 43 }) 44 }