-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_test.go
90 lines (79 loc) · 1.9 KB
/
client_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
85
86
87
88
89
90
package client
import (
"fmt"
"testing"
"time"
"github.com/stretchr/testify/require"
)
func TestGetLoginURL(t *testing.T) {
var testCases = []struct {
login string
password string
expect string
}{
{
"test@test.ru",
"pass",
"https://www.myfxbook.com/api/login.json?email=test@test.ru&password=pass",
},
{
"test@test.ru",
"",
"https://www.myfxbook.com/api/login.json?email=test@test.ru&password=",
},
}
for _, tc := range testCases {
result := getLoginURL(tc.login, tc.password)
if result != tc.expect {
t.Errorf("getLoginURL(%s, %s) expect %s got %s", tc.login, tc.password, tc.expect, result)
}
}
}
func TestGetLogoutURL(t *testing.T) {
var testCases = []struct {
session string
expect string
}{
{
"",
"https://www.myfxbook.com/api/logout.json?session=",
},
{
"something-session-string",
"https://www.myfxbook.com/api/logout.json?session=something-session-string",
},
}
for _, tc := range testCases {
result := getLogoutURL(tc.session)
if result != tc.expect {
t.Errorf("getLogoutURL(%s) expect %s got %s", tc.session, tc.expect, result)
}
}
}
func TestGetGetMyAccountsURL(t *testing.T) {
var testCases = []struct {
session string
expect string
}{
{
"",
"https://www.myfxbook.com/api/get-my-accounts.json?session=",
},
{
"something-session-string",
"https://www.myfxbook.com/api/get-my-accounts.json?session=something-session-string",
},
}
for _, tc := range testCases {
result := getGetMyAccountsURL(tc.session)
if result != tc.expect {
t.Errorf("getGetMyAccountsURL(%s) expect %s got %s", tc.session, tc.expect, result)
}
}
}
func TestLoadEconomicCalendar(t *testing.T) {
client := NewCalendar("", "", time.UTC)
items, err := client.FetchCalendarItems(timeFromString("2021-02-26 00:00"), timeFromString("2021-02-26 00:00"))
require.NoError(t, err)
fmt.Printf("%d, %+v", len(items), items)
}