-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhistory_listing_request_options_test.go
84 lines (71 loc) · 3.07 KB
/
history_listing_request_options_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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package moexiss
import "testing"
func TestHistoryListingTradingStatus_String(t *testing.T) {
if got, expected := ListingTradingStatusNotTraded.String(), "nottraded"; got != expected {
t.Fatalf("Error: expecting `%s` \ngot `%s` \ninstead", expected, got)
}
if got, expected := ListingTradingStatusAll.String(), "all"; got != expected {
t.Fatalf("Error: expecting `%s` \ngot `%s` \ninstead", expected, got)
}
if got, expected := ListingTradingStatusTraded.String(), "traded"; got != expected {
t.Fatalf("Error: expecting `%s` \ngot `%s` \ninstead", expected, got)
}
if got, expected := ListingTradingStatusUndefined.String(), ""; got != expected {
t.Fatalf("Error: expecting `%s` \ngot `%s` \ninstead", expected, got)
}
}
func TestHistoryListingRequestOptionsBuilder_Build(t *testing.T) {
expectStruct := HistoryListingRequestOptions{}
bld := NewHistoryListingReqOptionsBuilder()
if got, expected := *bld.Build(), expectStruct; got != expected {
t.Fatalf("Error: expecting `%v` HistoryListingRequestOptions \ngot `%v` HistoryListingRequestOptions \ninstead", expected, got)
}
}
func TestHistoryListingRequestOptionsBuilder_Lang(t *testing.T) {
expectStruct := HistoryListingRequestOptions{lang: LangEn}
bld := NewHistoryListingReqOptionsBuilder()
bld.Lang(LangEn)
if got, expected := *bld.Build(), expectStruct; got != expected {
t.Fatalf("Error: expecting `%v` \ngot `%v` \ninstead", expected, got)
}
}
func TestHistoryListingRequestOptionsBuilder_Start(t *testing.T) {
expectStruct := HistoryListingRequestOptions{start: 42}
bld := NewHistoryListingReqOptionsBuilder()
bld.Start(42)
if got, expected := *bld.Build(), expectStruct; got != expected {
t.Fatalf("Error: expecting `%v` \ngot `%v` \ninstead", expected, got)
}
}
func TestHistoryListingRequestOptionsBuilder_Status(t *testing.T) {
expectStruct := HistoryListingRequestOptions{status: ListingTradingStatusTraded}
bld := NewHistoryListingReqOptionsBuilder()
bld.Status(ListingTradingStatusTraded)
if got, expected := *bld.Build(), expectStruct; got != expected {
t.Fatalf("Error: expecting `%v` \ngot `%v` \ninstead", expected, got)
}
}
func TestAddHistoryListingRequestOptionsNil(t *testing.T) {
var income *HistoryListingRequestOptions = nil
c := NewClient(nil)
url, _ := c.BaseURL.Parse("test.json")
gotURL := addHistoryListingRequestOptions(url, income)
expected := `https://iss.moex.com/iss/test.json?iss.json=extended&iss.meta=off`
if got := gotURL.String(); got != expected {
t.Fatalf("Error: expecting url :\n`%s` \ngot \n`%s` \ninstead", expected, got)
}
}
func TestAddHistoryListingRequestOptions(t *testing.T) {
var income = NewHistoryListingReqOptionsBuilder().
Status(ListingTradingStatusNotTraded).
Start(42).
Lang(LangEn).
Build()
c := NewClient(nil)
url, _ := c.BaseURL.Parse("test.json")
gotURL := addHistoryListingRequestOptions(url, income)
expected := `https://iss.moex.com/iss/test.json?iss.json=extended&iss.meta=off&lang=en&start=42&status=nottraded`
if got := gotURL.String(); got != expected {
t.Fatalf("Error: expecting url :\n`%s` \ngot \n`%s` \ninstead", expected, got)
}
}