github.com/bitfinexcom/bitfinex-api-go@v0.0.0-20210608095005-9e0b26f200fb/pkg/models/balanceinfo/balanceinfo_test.go (about)

     1  package balanceinfo_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/bitfinexcom/bitfinex-api-go/pkg/models/balanceinfo"
     7  	"github.com/stretchr/testify/assert"
     8  	"github.com/stretchr/testify/require"
     9  )
    10  
    11  func TestBalanceInfoFromRaw(t *testing.T) {
    12  	t.Run("invalid arguments", func(t *testing.T) {
    13  		payload := []interface{}{4131.85}
    14  
    15  		b, err := balanceinfo.FromRaw(payload)
    16  		require.NotNil(t, err)
    17  		require.Nil(t, b)
    18  	})
    19  
    20  	t.Run("valid trading arguments", func(t *testing.T) {
    21  		payload := []interface{}{4131.85, 4131.85}
    22  
    23  		b, err := balanceinfo.FromRaw(payload)
    24  		require.Nil(t, err)
    25  
    26  		expected := &balanceinfo.BalanceInfo{
    27  			TotalAUM: 4131.85,
    28  			NetAUM:   4131.85,
    29  		}
    30  		assert.Equal(t, expected, b)
    31  	})
    32  }