This repository has been archived by the owner on Feb 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
coin_test.go
52 lines (44 loc) · 1.19 KB
/
coin_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package cryptocomparego
import (
"fmt"
"net/http"
"reflect"
"testing"
)
func TestCoinList(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/data/all/coinlist", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodGet)
response := `
{
"Response": "Success",
"Message": "Coin list succesfully returned!",
"BaseImageUrl": "https://www.cryptocompare.com",
"BaseLinkUrl": "https://www.cryptocompare.com",
"Data": {
"LTC": {
"Id": "3808",
"Url": "/coins/ltc/overview",
"ImageUrl": "/media/19782/ltc.png",
"Name": "LTC",
"CoinName": "Litecoin",
"FullName": "Litecoin (LTC)",
"Algorithm": "Scrypt",
"ProofType": "PoW",
"SortOrder": "2"
}
},
"Type": 100
}`
fmt.Fprint(w, response)
})
acct, _, err := client.Coin.List(ctx)
if err != nil {
t.Errorf("Coin.List returned error: %v", err)
}
expected := []Coin{{"3808", "https://www.cryptocompare.com/coins/ltc/overview", "https://www.cryptocompare.com/media/19782/ltc.png", "LTC", "Litecoin", "Litecoin (LTC)", "Scrypt", "PoW", "2"}}
if !reflect.DeepEqual(acct, expected) {
t.Errorf("Coin.List returned %+v, expected %+v", acct, expected)
}
}