forked from timpalpant/go-iex
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient_test.go
More file actions
60 lines (49 loc) · 1.08 KB
/
client_test.go
File metadata and controls
60 lines (49 loc) · 1.08 KB
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
53
54
55
56
57
58
59
60
package iex
import (
"net/http"
"testing"
"time"
)
func setupTestClient() *Client {
return NewClient(&http.Client{
Timeout: 5 * time.Second,
})
}
func testTOPS(t *testing.T, symbols []string) {
c := setupTestClient()
result, err := c.GetTOPS(symbols)
if err != nil {
t.Fatal(err)
}
if len(result) != len(symbols) {
t.Fatalf("Received %v results, expected %v", len(result), len(symbols))
}
// TODO(palpant): Test parsing with a mock http client.
}
func TestTOPS_OneSymbol(t *testing.T) {
testTOPS(t, []string{"SPY"})
}
func TestTOPS_TwoSymbols(t *testing.T) {
testTOPS(t, []string{"SPY", "AAPL"})
}
func TestTOPS_AllSymbols(t *testing.T) {
c := setupTestClient()
result, err := c.GetTOPS(nil)
if err != nil {
t.Fatal(err)
}
if len(result) == 0 {
t.Fatalf("Received %v results", len(result))
}
}
func TestLast(t *testing.T) {
c := setupTestClient()
symbols := []string{"SPY", "AAPL"}
result, err := c.GetLast(symbols)
if err != nil {
t.Fatal(err)
}
if len(result) != len(symbols) {
t.Fatalf("Received %v results, expected %v", len(result), len(symbols))
}
}