-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquery_test.go
66 lines (54 loc) · 1.33 KB
/
query_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
package bnm_test
import (
"testing"
"time"
"github.com/OsoianMarcel/bnm-go"
)
// Get specific date for testing
func getSpecificDate() (time.Time, error) {
return time.Parse("2006-Jan-02", "2017-Aug-05")
}
// Get specific query for testing
func getSpecificQuery() (bnm.Query, error) {
date, err := getSpecificDate()
if err != nil {
return bnm.Query{}, err
}
return bnm.NewQuery("ro", date), nil
}
// Test method DateToString()
func TestQuery_DateToString(t *testing.T) {
query, err := getSpecificQuery()
if err != nil {
t.Error(err)
}
expected := "05.08.2017"
result := query.DateToString()
if result != expected {
t.Errorf("incorrect date, expected: %s, result: %s", expected, result)
}
}
// Test method GenerateURI()
func TestQuery_GenerateURI(t *testing.T) {
query, err := getSpecificQuery()
if err != nil {
t.Error(err)
}
expected := "http://www.bnm.md/ro/official_exchange_rates?get_xml=1&date=05.08.2017"
result := query.GenerateURI()
if result != expected {
t.Errorf("incorrect URI, expected: %s, result: %s", expected, result)
}
}
// Test method GetID()
func TestQuery_GetID(t *testing.T) {
query, err := getSpecificQuery()
if err != nil {
t.Error(err)
}
expected := "ro_05.08.2017"
result := query.GetID()
if result != expected {
t.Errorf("incorrect id, expected: %s, result: %s", expected, result)
}
}