Lint Tests Passing
All checks were successful
Continuous Integration / CI (push) Successful in 1m40s
All checks were successful
Continuous Integration / CI (push) Successful in 1m40s
Made lint tests pass
This commit is contained in:
4
api.go
4
api.go
@@ -50,7 +50,7 @@ func (api *TastytradeAPI) fetchData(url string) (map[string]interface{}, error)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer func() { _ = resp.Body.Close() }()
|
||||||
|
|
||||||
if resp.StatusCode >= 400 && resp.StatusCode < 500 {
|
if resp.StatusCode >= 400 && resp.StatusCode < 500 {
|
||||||
return nil, fmt.Errorf("client error occurred: status code %d", resp.StatusCode)
|
return nil, fmt.Errorf("client error occurred: status code %d", resp.StatusCode)
|
||||||
@@ -78,7 +78,7 @@ func (api *TastytradeAPI) fetchDataAndUnmarshal(urlVal string, v interface{}) er
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer func() { _= resp.Body.Close() }()
|
||||||
|
|
||||||
if resp.StatusCode >= 400 && resp.StatusCode < 500 {
|
if resp.StatusCode >= 400 && resp.StatusCode < 500 {
|
||||||
return fmt.Errorf("client error occurred: status code %d", resp.StatusCode)
|
return fmt.Errorf("client error occurred: status code %d", resp.StatusCode)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
func TestFetchData(t *testing.T) {
|
func TestFetchData(t *testing.T) {
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
rw.Write([]byte(`{"data": "test"}`))
|
_,_ = rw.Write([]byte(`{"data": "test"}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ func TestFetchData(t *testing.T) {
|
|||||||
|
|
||||||
func TestFetchDataAndUnmarshal(t *testing.T) {
|
func TestFetchDataAndUnmarshal(t *testing.T) {
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
rw.Write([]byte(`{"data": "test"}`))
|
_,_ = rw.Write([]byte(`{"data": "test"}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ func TestGetAccountBalances(t *testing.T) {
|
|||||||
t.Errorf("got: %s, want: /accounts/123/balances", req.URL.String())
|
t.Errorf("got: %s, want: /accounts/123/balances", req.URL.String())
|
||||||
}
|
}
|
||||||
// Send response to be tested
|
// Send response to be tested
|
||||||
rw.Write([]byte(`{"data": {"account-number": "123", "cash-balance": "1000"}, "context": "test"}`))
|
_,_ = rw.Write([]byte(`{"data": {"account-number": "123", "cash-balance": "1000"}, "context": "test"}`))
|
||||||
}))
|
}))
|
||||||
// Close the server when test finishes
|
// Close the server when test finishes
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
func TestListCryptocurrencies(t *testing.T) {
|
func TestListCryptocurrencies(t *testing.T) {
|
||||||
// Create a test server that returns a dummy response
|
// Create a test server that returns a dummy response
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Write([]byte(`{"data": {"items": []}, "context": "/instruments/cryptocurrencies"}`))
|
_,_ = w.Write([]byte(`{"data": {"items": []}, "context": "/instruments/cryptocurrencies"}`))
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ func TestListCryptocurrencies(t *testing.T) {
|
|||||||
func TestGetCryptocurrency(t *testing.T) {
|
func TestGetCryptocurrency(t *testing.T) {
|
||||||
// Create a test server that returns a dummy response
|
// Create a test server that returns a dummy response
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Write([]byte(`{"data": {"symbol": "BTC/USD"}, "context": "/instruments/cryptocurrencies/BTC%2FUSD"}`))
|
_,_ = w.Write([]byte(`{"data": {"symbol": "BTC/USD"}, "context": "/instruments/cryptocurrencies/BTC%2FUSD"}`))
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
func TestGetCustomerInfo(t *testing.T) {
|
func TestGetCustomerInfo(t *testing.T) {
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
rw.Write([]byte(`{"context": "test", "data": {"id": "123", "first-name": "John", "last-name": "Doe"}}`))
|
_,_ = rw.Write([]byte(`{"context": "test", "data": {"id": "123", "first-name": "John", "last-name": "Doe"}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ func TestGetCustomerInfo(t *testing.T) {
|
|||||||
|
|
||||||
func TestListCustomerAccounts(t *testing.T) {
|
func TestListCustomerAccounts(t *testing.T) {
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
rw.Write([]byte(`{"context": "test", "data": {"items": [{"account": {"account-number": "123"}}]}}`))
|
_,_ = rw.Write([]byte(`{"context": "test", "data": {"items": [{"account": {"account-number": "123"}}]}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ func TestListCustomerAccounts(t *testing.T) {
|
|||||||
|
|
||||||
func TestGetAccount(t *testing.T) {
|
func TestGetAccount(t *testing.T) {
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
rw.Write([]byte(`{"context": "test", "data": {"account-number": "123"}}`))
|
_,_= rw.Write([]byte(`{"context": "test", "data": {"account-number": "123"}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
func TestGetEquityData(t *testing.T) {
|
func TestGetEquityData(t *testing.T) {
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
rw.Write([]byte(`{"context": "test", "data": {"symbol": "AAPL"}}`))
|
_,_ = rw.Write([]byte(`{"context": "test", "data": {"symbol": "AAPL"}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ func TestGetEquityData(t *testing.T) {
|
|||||||
|
|
||||||
func TestListEquities(t *testing.T) {
|
func TestListEquities(t *testing.T) {
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
rw.Write([]byte(`{"context": "test", "data": {"items": [{"symbol": "AAPL"}, {"symbol": "GOOG"}]}}`))
|
_,_ = rw.Write([]byte(`{"context": "test", "data": {"items": [{"symbol": "AAPL"}, {"symbol": "GOOG"}]}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ func TestListEquities(t *testing.T) {
|
|||||||
|
|
||||||
func TestListActiveEquities(t *testing.T) {
|
func TestListActiveEquities(t *testing.T) {
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
rw.Write([]byte(`{"context": "test", "data": {"items": [{"symbol": "AAPL"}, {"symbol": "GOOG"}]}}`))
|
_,_ = rw.Write([]byte(`{"context": "test", "data": {"items": [{"symbol": "AAPL"}, {"symbol": "GOOG"}]}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ func TestQueryFutures(t *testing.T) {
|
|||||||
if req.URL.String() != expectedURL {
|
if req.URL.String() != expectedURL {
|
||||||
t.Errorf("expected URL to be %s, got %s", expectedURL, req.URL.String())
|
t.Errorf("expected URL to be %s, got %s", expectedURL, req.URL.String())
|
||||||
}
|
}
|
||||||
rw.Write([]byte(`{"data": {"items": [{"symbol": "AAPL"}]}}`))
|
_,_ = rw.Write([]byte(`{"data": {"items": [{"symbol": "AAPL"}]}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ func TestQueryFuturesWithParams(t *testing.T) {
|
|||||||
if req.URL.String() != expectedURL {
|
if req.URL.String() != expectedURL {
|
||||||
t.Errorf("expected URL to be %s, got %s", expectedURL, req.URL.String())
|
t.Errorf("expected URL to be %s, got %s", expectedURL, req.URL.String())
|
||||||
}
|
}
|
||||||
rw.Write([]byte(`{"data": {"items": [{"symbol": "AAPL", "product-code": "123"}]}}`))
|
_,_ = rw.Write([]byte(`{"data": {"items": [{"symbol": "AAPL", "product-code": "123"}]}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ func TestGetFuture(t *testing.T) {
|
|||||||
if req.URL.String() != expectedURL {
|
if req.URL.String() != expectedURL {
|
||||||
t.Errorf("expected URL to be %s, got %s", expectedURL, req.URL.String())
|
t.Errorf("expected URL to be %s, got %s", expectedURL, req.URL.String())
|
||||||
}
|
}
|
||||||
rw.Write([]byte(`{"data": {"symbol": "AAPL"}}`))
|
_,_ = rw.Write([]byte(`{"data": {"symbol": "AAPL"}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ func TestGetFutureOptionProduct(t *testing.T) {
|
|||||||
if req.URL.String() != expectedURL {
|
if req.URL.String() != expectedURL {
|
||||||
t.Errorf("expected URL to be %s, got %s", expectedURL, req.URL.String())
|
t.Errorf("expected URL to be %s, got %s", expectedURL, req.URL.String())
|
||||||
}
|
}
|
||||||
rw.Write([]byte(`{"context": "test", "data": {"root-symbol": "AAPL"}}`))
|
_,_ = rw.Write([]byte(`{"context": "test", "data": {"root-symbol": "AAPL"}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ func TestListFutureOptions(t *testing.T) {
|
|||||||
if req.URL.String() != expectedURL {
|
if req.URL.String() != expectedURL {
|
||||||
t.Errorf("expected URL to be %s, got %s", expectedURL, req.URL.String())
|
t.Errorf("expected URL to be %s, got %s", expectedURL, req.URL.String())
|
||||||
}
|
}
|
||||||
rw.Write([]byte(`{"context": "test", "data": {"items": [{"symbol": "AAPL", "instrument-type": "future-option"}]}}`))
|
_,_ = rw.Write([]byte(`{"context": "test", "data": {"items": [{"symbol": "AAPL", "instrument-type": "future-option"}]}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ func TestListFutureOptionChainsNested(t *testing.T) {
|
|||||||
if req.URL.String() != expectedURL {
|
if req.URL.String() != expectedURL {
|
||||||
t.Errorf("expected URL to be %s, got %s", expectedURL, req.URL.String())
|
t.Errorf("expected URL to be %s, got %s", expectedURL, req.URL.String())
|
||||||
}
|
}
|
||||||
rw.Write([]byte(`{"context": "test", "data": {"futures": [{"symbol": "AAPL"}], "option-chains": [{"underlying-symbol": "AAPL"}]}}`))
|
_,_ = rw.Write([]byte(`{"context": "test", "data": {"futures": [{"symbol": "AAPL"}], "option-chains": [{"underlying-symbol": "AAPL"}]}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ func TestListFutureOptionChainsDetailed(t *testing.T) {
|
|||||||
if req.URL.String() != expectedURL {
|
if req.URL.String() != expectedURL {
|
||||||
t.Errorf("expected URL to be %s, got %s", expectedURL, req.URL.String())
|
t.Errorf("expected URL to be %s, got %s", expectedURL, req.URL.String())
|
||||||
}
|
}
|
||||||
rw.Write([]byte(`{"context": "test", "data": {"items": [{"symbol": "AAPL", "underlying-symbol": "AAPL"}]}}`))
|
_,_ = rw.Write([]byte(`{"context": "test", "data": {"items": [{"symbol": "AAPL", "underlying-symbol": "AAPL"}]}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
@@ -235,7 +235,7 @@ func TestGetFutureOption(t *testing.T) {
|
|||||||
if req.URL.String() != expectedURL {
|
if req.URL.String() != expectedURL {
|
||||||
t.Errorf("expected URL to be %s, got %s", expectedURL, req.URL.String())
|
t.Errorf("expected URL to be %s, got %s", expectedURL, req.URL.String())
|
||||||
}
|
}
|
||||||
rw.Write([]byte(`{"context": "test", "data": {"symbol": "AAPL", "instrument-type": "future-option"}}`))
|
_,_ = rw.Write([]byte(`{"context": "test", "data": {"symbol": "AAPL", "instrument-type": "future-option"}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
@@ -261,7 +261,7 @@ func TestListFutureOptionProducts(t *testing.T) {
|
|||||||
if req.URL.String() != expectedURL {
|
if req.URL.String() != expectedURL {
|
||||||
t.Errorf("expected URL to be %s, got %s", expectedURL, req.URL.String())
|
t.Errorf("expected URL to be %s, got %s", expectedURL, req.URL.String())
|
||||||
}
|
}
|
||||||
rw.Write([]byte(`{"context": "test", "data": {"items": [{"root-symbol": "AAPL", "instrument-type": "future-option"}]}}`))
|
_,_ = rw.Write([]byte(`{"context": "test", "data": {"items": [{"root-symbol": "AAPL", "instrument-type": "future-option"}]}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
func TestListOptionsChainsDetailed(t *testing.T) {
|
func TestListOptionsChainsDetailed(t *testing.T) {
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
rw.Write([]byte(`{"context": "test", "data": {"items": [{"symbol": "AAPL", "underlying-symbol": "AAPL"}]}}`))
|
_,_ = rw.Write([]byte(`{"context": "test", "data": {"items": [{"symbol": "AAPL", "underlying-symbol": "AAPL"}]}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ func TestListOptionsChainsDetailed(t *testing.T) {
|
|||||||
|
|
||||||
func TestListOptionChainsNested(t *testing.T) {
|
func TestListOptionChainsNested(t *testing.T) {
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
rw.Write([]byte(`{"context": "test", "data": {"items": [{"underlying-symbol": "AAPL", "root-symbol": "AAPL"}]}}`))
|
_,_ = rw.Write([]byte(`{"context": "test", "data": {"items": [{"underlying-symbol": "AAPL", "root-symbol": "AAPL"}]}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ func TestListOptionChainsNested(t *testing.T) {
|
|||||||
|
|
||||||
func TestGetOptionChainsCompact(t *testing.T) {
|
func TestGetOptionChainsCompact(t *testing.T) {
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
rw.Write([]byte(`{"context": "test", "data": {"items": [{"underlying-symbol": "AAPL", "root-symbol": "AAPL"}]}}`))
|
_,_ = rw.Write([]byte(`{"context": "test", "data": {"items": [{"underlying-symbol": "AAPL", "root-symbol": "AAPL"}]}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ func TestGetOptionChainsCompact(t *testing.T) {
|
|||||||
|
|
||||||
func TestGetEquityOptions(t *testing.T) {
|
func TestGetEquityOptions(t *testing.T) {
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
rw.Write([]byte(`{"context": "test", "data": {"items": [{"symbol": "AAPL", "instrument-type": "equity-option"}]}}`))
|
_,_ = rw.Write([]byte(`{"context": "test", "data": {"items": [{"symbol": "AAPL", "instrument-type": "equity-option"}]}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ func TestGetEquityOptions(t *testing.T) {
|
|||||||
|
|
||||||
func TestGetEquityOption(t *testing.T) {
|
func TestGetEquityOption(t *testing.T) {
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
rw.Write([]byte(`{"context": "test", "data": {"symbol": "AAPL", "instrument-type": "equity-option"}}`))
|
_,_ = rw.Write([]byte(`{"context": "test", "data": {"symbol": "AAPL", "instrument-type": "equity-option"}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
func TestGetPositions(t *testing.T) {
|
func TestGetPositions(t *testing.T) {
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
rw.Write([]byte(`{"context": "test", "data": {"items": [{"symbol": "AAPL", "quantity": "100"}]}}`))
|
_,_ = rw.Write([]byte(`{"context": "test", "data": {"items": [{"symbol": "AAPL", "quantity": "100"}]}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ func (api *TastytradeAPI) Authenticate2(username, password string, remember bool
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer func() { _ = resp.Body.Close() }()
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated {
|
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated {
|
||||||
return fmt.Errorf("authentication failed: status code %d", resp.StatusCode)
|
return fmt.Errorf("authentication failed: status code %d", resp.StatusCode)
|
||||||
@@ -97,7 +97,7 @@ func (api *TastytradeAPI) AuthRemember(remember bool) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer func() { _ = resp.Body.Close() }()
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated {
|
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated {
|
||||||
return fmt.Errorf("authentication failed: status code %d", resp.StatusCode)
|
return fmt.Errorf("authentication failed: status code %d", resp.StatusCode)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
func TestAuthenticate(t *testing.T) {
|
func TestAuthenticate(t *testing.T) {
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
rw.Write([]byte(`{"context": "test", "data": {"user": {"email": "test@example.com", "username": "testuser", "external-id": "123", "is-confirmed": true}, "session-token": "testtoken"}}`))
|
_,_ = rw.Write([]byte(`{"context": "test", "data": {"user": {"email": "test@example.com", "username": "testuser", "external-id": "123", "is-confirmed": true}, "session-token": "testtoken"}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ func TestAuthenticate(t *testing.T) {
|
|||||||
|
|
||||||
func TestAuthenticate2(t *testing.T) {
|
func TestAuthenticate2(t *testing.T) {
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
rw.Write([]byte(`{"context": "test", "data": {"user": {"email": "test@example.com", "username": "testuser", "external-id": "123", "is-confirmed": true}, "session-token": "testtoken", "remember-token": "remember", "session-expiration": "2024-09-12T20:25:32.440Z"}}`))
|
_,_ = rw.Write([]byte(`{"context": "test", "data": {"user": {"email": "test@example.com", "username": "testuser", "external-id": "123", "is-confirmed": true}, "session-token": "testtoken", "remember-token": "remember", "session-expiration": "2024-09-12T20:25:32.440Z"}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ func TestAuthenticate2(t *testing.T) {
|
|||||||
|
|
||||||
func TestAuthRemember(t *testing.T) {
|
func TestAuthRemember(t *testing.T) {
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
rw.Write([]byte(`{"context": "test", "data": {"user": {"email": "test@example.com", "username": "testuser", "external-id": "123", "is-confirmed": true}, "session-token": "testtoken", "remember-token": "remember-new"}}`))
|
_,_ = rw.Write([]byte(`{"context": "test", "data": {"user": {"email": "test@example.com", "username": "testuser", "external-id": "123", "is-confirmed": true}, "session-token": "testtoken", "remember-token": "remember-new"}}`))
|
||||||
}))
|
}))
|
||||||
var err error
|
var err error
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
func TestGetAccountTradingStatus(t *testing.T) {
|
func TestGetAccountTradingStatus(t *testing.T) {
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
rw.Write([]byte(`{"context": "test", "data": {"account-number": "123456", "day-trade-count": 1}}`))
|
_,_ = rw.Write([]byte(`{"context": "test", "data": {"account-number": "123456", "day-trade-count": 1}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
func TestGetTransactions(t *testing.T) {
|
func TestGetTransactions(t *testing.T) {
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
rw.Write([]byte(`{"context": "test", "data": {"items": [{"id": 1, "account-number": "123456", "symbol": "AAPL", "transaction-type": "buy"}]}}`))
|
_,_ = rw.Write([]byte(`{"context": "test", "data": {"items": [{"id": 1, "account-number": "123456", "symbol": "AAPL", "transaction-type": "buy"}]}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ func TestGetTransactions(t *testing.T) {
|
|||||||
|
|
||||||
func TestGetTransaction(t *testing.T) {
|
func TestGetTransaction(t *testing.T) {
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
rw.Write([]byte(`{"context": "test", "data": {"id": 1, "account-number": "123", "symbol": "AAPL", "instrument-type": "equity-option"}}`))
|
_,_ = rw.Write([]byte(`{"context": "test", "data": {"id": 1, "account-number": "123", "symbol": "AAPL", "instrument-type": "equity-option"}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ func TestGetTransaction(t *testing.T) {
|
|||||||
|
|
||||||
func TestGetTransactionsPagination(t *testing.T) {
|
func TestGetTransactionsPagination(t *testing.T) {
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
rw.Write([]byte(`{"api-version": "1.0", "context": "test", "data": {"items": [{"id": 1, "account-number": "123", "symbol": "AAPL", "instrument-type": "equity-option"}]}, "pagination": {"per-page": 1, "total-items": 10}}`))
|
_,_ = rw.Write([]byte(`{"api-version": "1.0", "context": "test", "data": {"items": [{"id": 1, "account-number": "123", "symbol": "AAPL", "instrument-type": "equity-option"}]}, "pagination": {"per-page": 1, "total-items": 10}}`))
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
func TestListWarrants(t *testing.T) {
|
func TestListWarrants(t *testing.T) {
|
||||||
// Create a test server that returns a dummy response
|
// Create a test server that returns a dummy response
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Write([]byte(`{"data": {"items": []}, "context": "/instruments/warrants"}`))
|
_,_ = w.Write([]byte(`{"data": {"items": []}, "context": "/instruments/warrants"}`))
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ func TestListWarrants(t *testing.T) {
|
|||||||
func TestGetWarrant(t *testing.T) {
|
func TestGetWarrant(t *testing.T) {
|
||||||
// Create a test server that returns a dummy response
|
// Create a test server that returns a dummy response
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Write([]byte(`{"data": {"symbol": "SEPAW"}, "context": "/instruments/warrants/SEPAW"}`))
|
_,_ = w.Write([]byte(`{"data": {"symbol": "SEPAW"}, "context": "/instruments/warrants/SEPAW"}`))
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user