github.com/bitfinexcom/bitfinex-api-go@v0.0.0-20210608095005-9e0b26f200fb/pkg/models/trades/authtradeexecutionupdate_test.go (about) 1 package trades_test 2 3 import ( 4 "testing" 5 6 "github.com/bitfinexcom/bitfinex-api-go/pkg/models/trades" 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func TestAuthenticatedTradeExecutionUpdateFromRaw(t *testing.T) { 11 cases := map[string]struct { 12 pld []interface{} 13 expected trades.AuthTradeExecutionUpdate 14 err func(*testing.T, error) 15 }{ 16 "invalid payload": { 17 pld: []interface{}{402088407}, 18 expected: trades.AuthTradeExecutionUpdate{}, 19 err: func(t *testing.T, err error) { 20 assert.Error(t, err) 21 }, 22 }, 23 "valid payload": { 24 pld: []interface{}{ 25 402088407, "tETHUST", 1574963975602, 34938060782, 26 -0.2, 153.57, "MARKET", 0, -1, -0.061668, "USD", 27 }, 28 expected: trades.AuthTradeExecutionUpdate{ 29 ID: 402088407, 30 Pair: "tETHUST", 31 MTS: 1574963975602, 32 OrderID: 34938060782, 33 ExecAmount: -0.2, 34 ExecPrice: 153.57, 35 OrderType: "MARKET", 36 OrderPrice: 0, 37 Maker: -1, 38 Fee: -0.061668, 39 FeeCurrency: "USD", 40 }, 41 err: func(t *testing.T, err error) { 42 assert.NoError(t, err) 43 }, 44 }, 45 } 46 47 for k, v := range cases { 48 t.Run(k, func(t *testing.T) { 49 got, err := trades.ATEUFromRaw(v.pld) 50 v.err(t, err) 51 assert.Equal(t, v.expected, got) 52 }) 53 } 54 }