mirror of
https://github.com/tiennm99/tcbs-api.git
synced 2026-06-10 00:14:14 +00:00
ee236d1fe0
- Split monolithic models.go (738 lines) into 6 domain files - Fix schema drift: BasicInfo, PersonalInfo, TotalCashDerivativeResponse, derivative order types, money transfer types aligned to spec - Add missing REST endpoints: bsa-ext, bsa-month (supply/demand) - Add WebSocket support for 5 streaming endpoints (nhooyr.io/websocket) - Add 45 httptest-based tests (74.9% coverage) - Rewrite README with full API coverage table BREAKING CHANGE: struct fields and types changed to match OpenAPI spec. BasicInfo reduced to 5 fields, TokenResponse uses 'token' field, PlaceOrderRequest uses int types, derivative order types renamed.
31 lines
770 B
Go
31 lines
770 B
Go
package tcbs
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"testing"
|
|
)
|
|
|
|
func TestGetToken(t *testing.T) {
|
|
client, _ := newTestServer(t, func(w http.ResponseWriter, r *http.Request) {
|
|
if r.Method != http.MethodPost {
|
|
t.Errorf("expected POST, got %s", r.Method)
|
|
}
|
|
if r.URL.Path != "/gaia/v1/oauth2/openapi/token" {
|
|
t.Errorf("unexpected path: %s", r.URL.Path)
|
|
}
|
|
writeJSON(t, w, TokenResponse{Token: "jwt-123"})
|
|
})
|
|
|
|
resp, err := client.GetToken(context.Background(), "key", "otp")
|
|
if err != nil {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
if resp.Token != "jwt-123" {
|
|
t.Errorf("expected token 'jwt-123', got %q", resp.Token)
|
|
}
|
|
if client.currentToken() != "jwt-123" {
|
|
t.Errorf("expected client token updated to 'jwt-123', got %q", client.currentToken())
|
|
}
|
|
}
|