github.com/bitfinexcom/bitfinex-api-go@v0.0.0-20210608095005-9e0b26f200fb/pkg/models/invoice/invoice_test.go (about) 1 package invoice_test 2 3 import ( 4 "testing" 5 6 "github.com/bitfinexcom/bitfinex-api-go/pkg/models/invoice" 7 "github.com/stretchr/testify/assert" 8 "github.com/stretchr/testify/require" 9 ) 10 11 func TestNewInvoiceFromRaw(t *testing.T) { 12 t.Run("insufficient arguments", func(t *testing.T) { 13 payload := []interface{}{"invoicehash"} 14 15 invc, err := invoice.NewFromRaw(payload) 16 require.NotNil(t, err) 17 require.Nil(t, invc) 18 }) 19 20 t.Run("valid arguments", func(t *testing.T) { 21 payload := []interface{}{ 22 "invoicehash", 23 "invoice", 24 nil, 25 nil, 26 "0.00016", 27 } 28 29 invc, err := invoice.NewFromRaw(payload) 30 require.Nil(t, err) 31 32 expected := &invoice.Invoice{ 33 InvoiceHash: "invoicehash", 34 Invoice: "invoice", 35 Amount: "0.00016", 36 } 37 38 assert.Equal(t, expected, invc) 39 }) 40 }