github.com/bitfinexcom/bitfinex-api-go@v0.0.0-20210608095005-9e0b26f200fb/v1/stats_test.go (about) 1 package bitfinex 2 3 import ( 4 "bytes" 5 "io/ioutil" 6 "net/http" 7 "testing" 8 ) 9 10 func TestStatsAll(t *testing.T) { 11 httpDo = func(req *http.Request) (*http.Response, error) { 12 msg := `[{ 13 "period":1, 14 "volume":"7967.96766158" 15 },{ 16 "period":7, 17 "volume":"55938.67260266" 18 },{ 19 "period":30, 20 "volume":"275148.09653645" 21 }]` 22 resp := http.Response{ 23 Body: ioutil.NopCloser(bytes.NewBufferString(msg)), 24 StatusCode: 200, 25 } 26 return &resp, nil 27 } 28 29 stats, err := NewClient().Stats.All("btcusd", "10", "") 30 31 if err != nil { 32 t.Error(err) 33 } 34 35 if len(stats) != 3 { 36 t.Error("Expected", 3) 37 t.Error("Actual ", len(stats)) 38 } 39 }