-
Notifications
You must be signed in to change notification settings - Fork 2
/
indices_quotes_test.go
58 lines (49 loc) · 1.25 KB
/
indices_quotes_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
53
54
55
56
57
58
package client
import (
"context"
"testing"
)
func TestIndexQuoteRequest_Packed(t *testing.T) {
ctx := context.TODO()
iqPacked, err := IndexQuotes().Symbol("VIX").FiftyTwoWeek(true).Packed(ctx)
if err != nil {
t.Errorf("Failed to get index quotes: %v", err)
return
}
iq, err := iqPacked.Unpack()
if err != nil {
t.Errorf("Failed to unpack index quotes: %v", err)
return
}
if len(iq) == 0 {
t.Errorf("Unpacked index quotes slice is empty")
return
}
firstQuote := iq[0]
if firstQuote.Symbol != "VIX" {
t.Errorf("Expected symbol VIX, got %s", firstQuote.Symbol)
}
if firstQuote.Last < 0 || firstQuote.Last > 100 {
t.Errorf("Expected last value to be between 0 and 100, got %f", firstQuote.Last)
}
}
func TestIndexQuoteRequest_Get(t *testing.T) {
ctx := context.TODO()
iq, err := IndexQuotes().Symbol("VIX").FiftyTwoWeek(false).Get(ctx)
if err != nil {
t.Errorf("Failed to get index quotes: %v", err)
return
}
if len(iq) == 0 {
t.Errorf("Index quotes slice is empty")
return
}
for _, quote := range iq {
if quote.Symbol != "VIX" {
t.Errorf("Expected symbol VIX, got %s", quote.Symbol)
}
if quote.Last < 0 || quote.Last > 100 {
t.Errorf("Expected last value to be between 0 and 100, got %f", quote.Last)
}
}
}