-
Notifications
You must be signed in to change notification settings - Fork 3
/
api_system_metadata_test.go
58 lines (49 loc) · 1.23 KB
/
api_system_metadata_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 goiex
import (
"log"
"net/http"
"net/url"
"testing"
"github.com/dnaeon/go-vcr/recorder"
)
func TestNewAPISystemMetadata(t *testing.T) {
u, _ := url.Parse(SandboxBaseURL)
asm := NewAPISystemMetadata("test_token", "", u, nil)
expected = "https://sandbox.iexapis.com/"
actual = asm.URL().String()
if expected != actual {
t.Errorf("\nExpected: %s\nActual: %s\n", expected, actual)
}
expected = ""
actual = asm.APIURL().String()
if expected != actual {
t.Errorf("\nExpected: %s\nActual: %s\n", expected, actual)
}
expected = "test_token"
actual = asm.Token()
if expected != actual {
t.Errorf("\nExpected: %s\nActual: %s\n", expected, actual)
}
}
func TestStatus(t *testing.T) {
rec, err := recorder.New("cassettes/api_system_metadata/status")
if err != nil {
log.Fatal(err)
} else {
rec.SetMatcher(matchWithoutToken)
httpClient = &http.Client{Transport: rec}
}
rec.AddFilter(removeToken)
defer rec.Stop()
u, _ := url.Parse(SandboxBaseURL)
cli := NewAPISystemMetadata(testToken, DefaultVersion, u, httpClient)
status, err := cli.Status()
if err != nil {
t.Error(err)
}
expected = `up`
actual = status.Status
if expected != actual {
t.Errorf("\nExpected: %v\nActual: %v\n", expected, actual)
}
}