mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-14 16:26:57 +08:00
refactor: restructure project directories for better modularity
- Delete llm/ dead code (3 files, zero references) - Split mcp/ into sub-packages: mcp/provider/ (8 providers) and mcp/payment/ (4 payment clients) with registry pattern - Export Client internal fields and ClientHooks interface for sub-package access - Split api/server.go (3892 lines) into 8 domain-specific handler files - Split trader/auto_trader.go (2296 lines) into 5 focused files - Reorganize web/src/components/ flat files into auth/, charts/, trader/, common/, modals/, backtest/ subdirectories - Update all consumer imports to use registry-based provider creation
This commit is contained in:
@@ -27,16 +27,16 @@ func TestNewClient_Default(t *testing.T) {
|
||||
t.Error("MaxTokens should be positive")
|
||||
}
|
||||
|
||||
if c.logger == nil {
|
||||
t.Error("logger should not be nil")
|
||||
if c.Log == nil {
|
||||
t.Error("Log should not be nil")
|
||||
}
|
||||
|
||||
if c.httpClient == nil {
|
||||
t.Error("httpClient should not be nil")
|
||||
if c.HTTPClient == nil {
|
||||
t.Error("HTTPClient should not be nil")
|
||||
}
|
||||
|
||||
if c.hooks == nil {
|
||||
t.Error("hooks should not be nil")
|
||||
if c.Hooks == nil {
|
||||
t.Error("Hooks should not be nil")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,12 +54,12 @@ func TestNewClient_WithOptions(t *testing.T) {
|
||||
|
||||
c := client.(*Client)
|
||||
|
||||
if c.logger != mockLogger {
|
||||
t.Error("logger should be set from option")
|
||||
if c.Log != mockLogger {
|
||||
t.Error("Log should be set from option")
|
||||
}
|
||||
|
||||
if c.httpClient != mockHTTP {
|
||||
t.Error("httpClient should be set from option")
|
||||
if c.HTTPClient != mockHTTP {
|
||||
t.Error("HTTPClient should be set from option")
|
||||
}
|
||||
|
||||
if c.MaxTokens != 4000 {
|
||||
@@ -174,7 +174,7 @@ func TestClient_Retry_Success(t *testing.T) {
|
||||
WithMaxRetries(3),
|
||||
)
|
||||
|
||||
// Since our client uses hooks.call, need special handling
|
||||
// Since our client uses Hooks.Call, need special handling
|
||||
// Here we test that CallWithMessages will invoke retry logic
|
||||
c := client.(*Client)
|
||||
|
||||
@@ -242,7 +242,7 @@ func TestClient_BuildMCPRequestBody(t *testing.T) {
|
||||
client := NewClient()
|
||||
c := client.(*Client)
|
||||
|
||||
body := c.buildMCPRequestBody("system prompt", "user prompt")
|
||||
body := c.BuildMCPRequestBody("system prompt", "user prompt")
|
||||
|
||||
if body == nil {
|
||||
t.Fatal("body should not be nil")
|
||||
@@ -300,7 +300,7 @@ func TestClient_BuildUrl(t *testing.T) {
|
||||
)
|
||||
c := client.(*Client)
|
||||
|
||||
url := c.buildUrl()
|
||||
url := c.BuildUrl()
|
||||
if url != tt.expected {
|
||||
t.Errorf("expected '%s', got '%s'", tt.expected, url)
|
||||
}
|
||||
@@ -313,7 +313,7 @@ func TestClient_SetAuthHeader(t *testing.T) {
|
||||
c := client.(*Client)
|
||||
|
||||
headers := make(http.Header)
|
||||
c.setAuthHeader(headers)
|
||||
c.SetAuthHeader(headers)
|
||||
|
||||
authHeader := headers.Get("Authorization")
|
||||
if authHeader != "Bearer test-api-key" {
|
||||
@@ -359,7 +359,7 @@ func TestClient_IsRetryableError(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
result := c.isRetryableError(tt.err)
|
||||
result := c.IsRetryableError(tt.err)
|
||||
if result != tt.expected {
|
||||
t.Errorf("expected %v, got %v", tt.expected, result)
|
||||
}
|
||||
@@ -378,8 +378,8 @@ func TestClient_SetTimeout(t *testing.T) {
|
||||
client.SetTimeout(newTimeout)
|
||||
|
||||
c := client.(*Client)
|
||||
if c.httpClient.Timeout != newTimeout {
|
||||
t.Errorf("expected timeout %v, got %v", newTimeout, c.httpClient.Timeout)
|
||||
if c.HTTPClient.Timeout != newTimeout {
|
||||
t.Errorf("expected timeout %v, got %v", newTimeout, c.HTTPClient.Timeout)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user