github.com/bitfinexcom/bitfinex-api-go@v0.0.0-20210608095005-9e0b26f200fb/v1/margin_funding_test.go (about) 1 package bitfinex 2 3 import ( 4 "bytes" 5 "io/ioutil" 6 "net/http" 7 "testing" 8 ) 9 10 func TestMarginFundingNew(t *testing.T) { 11 httpDo = func(req *http.Request) (*http.Response, error) { 12 msg := `{ 13 "id":13800585, 14 "currency":"USD", 15 "rate":"20.0", 16 "period":2, 17 "direction":"lend", 18 "timestamp":"1444279698.21175971", 19 "is_live":true, 20 "is_cancelled":false, 21 "original_amount":"50.0", 22 "remaining_amount":"50.0", 23 "executed_amount":"0.0", 24 "offer_id":13800585 25 }` 26 resp := http.Response{ 27 Body: ioutil.NopCloser(bytes.NewBufferString(msg)), 28 StatusCode: 200, 29 } 30 return &resp, nil 31 } 32 33 offer, err := NewClient().MarginFunding.new("BTC", "loan", 10.0, 0.01, 10) 34 35 if err != nil { 36 t.Error(err) 37 } 38 39 if offer.ID != 13800585 { 40 t.Error("Expected", 13800585) 41 t.Error("Actual ", offer.ID) 42 } 43 if !offer.IsLive { 44 t.Error("Expected", true) 45 t.Error("Actual ", offer.IsLive) 46 } 47 }