github.com/bitfinexcom/bitfinex-api-go@v0.0.0-20210608095005-9e0b26f200fb/v1/ticker_test.go (about) 1 package bitfinex 2 3 import ( 4 "bytes" 5 "io/ioutil" 6 "net/http" 7 "testing" 8 ) 9 10 func TestTickerGet(t *testing.T) { 11 httpDo = func(req *http.Request) (*http.Response, error) { 12 msg := `{ 13 "mid":"244.755", 14 "bid":"244.75", 15 "ask":"244.76", 16 "last_price":"244.82", 17 "low":"244.2", 18 "high":"248.19", 19 "volume":"7842.11542563", 20 "timestamp":"1444253422.348340958" 21 }` 22 resp := http.Response{ 23 Body: ioutil.NopCloser(bytes.NewBufferString(msg)), 24 StatusCode: 200, 25 } 26 return &resp, nil 27 } 28 29 tick, err := NewClient().Ticker.Get("btcusd") 30 31 if err != nil { 32 t.Error(err) 33 } 34 35 if tick.Bid != "244.75" { 36 t.Error("Expected", "244.75") 37 t.Error("Actual ", tick.Bid) 38 } 39 if tick.LastPrice != "244.82" { 40 t.Error("Expected", "244.82") 41 t.Error("Actual ", tick.LastPrice) 42 } 43 }