INNER CODE UNIT · Go
TestBuildURL
coinrust/trading-strategies · fxmacrodata/client_test.go:10
func TestBuildURL(t *testing.T) {
client := NewClient("test-key")
got := client.buildURL("/forex/aud/usd", nil)
want := "https://api.fxmacrodata.com/v1/forex/aud/usd"
if got != want {
t.Fatalf("got %q want %q", got, want)
}
}
func TestForexPage(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/forex/eur/usd" {
t.Errorf("unexpected path %q", r.URL.Path)
}
if r.URL.RawQuery != "limit=100&offset=200" {
t.Errorf("unexpected query %q", r.URL.RawQuery)
}
w.Write([]byte("{}"))