forked from gofinance/ib
-
Notifications
You must be signed in to change notification settings - Fork 1
/
metadata_manager_test.go
67 lines (48 loc) · 1.33 KB
/
metadata_manager_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
59
60
61
62
63
64
65
66
67
package ib
import (
"testing"
"time"
)
func TestMetadataManagerWithCompleteContractSpec(t *testing.T) {
engine := NewTestEngine(t)
defer engine.ConditionalStop(t)
contract := Contract{
Symbol: "ORCL",
SecurityType: "STK",
Exchange: "SMART",
Currency: "USD",
}
m, err := NewMetadataManager(engine, contract)
if err != nil {
t.Fatalf("error creating manager: %s", err)
}
defer m.Close()
SinkManagerTest(t, m, 15*time.Second, 1)
if len(m.ContractData()) != 1 {
t.Fatalf("Expected 1 contract data to be returned")
}
if m.ContractData()[0].Contract.Industry != "Technology" {
t.Fatalf("Expected contract to be 'Technology', not '%v'", m.ContractData()[0].Contract.Industry)
}
m.Contract()
}
func TestMetadataManagerWithIncompleteContractSpec(t *testing.T) {
engine := NewTestEngine(t)
defer engine.ConditionalStop(t)
contract := Contract{
Symbol: "SX4E",
Exchange: "DTB",
}
m, err := NewMetadataManager(engine, contract)
if err != nil {
t.Fatalf("error creating manager: %s", err)
}
defer m.Close()
SinkManagerTest(t, m, 15*time.Second, 1)
if len(m.ContractData()) != 1 {
t.Fatalf("Expected 1 contract to be returned")
}
if m.ContractData()[0].Contract.Summary.Currency != "EUR" {
t.Fatalf("Expected currency to be 'EUR', not '%v'", m.ContractData()[0].Contract.Summary.Currency)
}
}