refactor: rename action→activity, statemachine→workflow, remove HTTP API layer
- action/ → activity/ (Temporal activities) - statemachine/ → workflow/ (Temporal workflows) - Removed internal/api/ and cmd/server/ (api-gw handles HTTP, Temporal is the API) - Created pkg/types/types.go as single source of truth for all shared types - Extracted CallRoleLLM helper (DRY: implementer/planner/judge shared pattern) - Fixed circular import: workflow_graph_query uses string activity names - Fixed logger.logf → logger.Info/Warn (method didn't exist) - Fixed routing types: added Branches, Activity, BackoffSeconds, TaskActivity - Fixed db.Canvas.Name, db.Client→DB, GetWorkflow→FetchWorkflow - Removed unused imports - All tests pass, build clean, vet clean
This commit is contained in:
@@ -1,100 +0,0 @@
|
||||
package llm
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/rockliang/poimen/workflows/statemachine"
|
||||
)
|
||||
|
||||
func TestNewClient(t *testing.T) {
|
||||
client, err := NewClient()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create client: %v", err)
|
||||
}
|
||||
if client == nil {
|
||||
t.Fatal("client is nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHealthCheck(t *testing.T) {
|
||||
client, err := NewClient()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create client: %v", err)
|
||||
}
|
||||
|
||||
// Skip if local LLM API not available
|
||||
err = client.HealthCheck(context.Background())
|
||||
if err != nil {
|
||||
t.Logf("local LLM API not available (expected in test env): %v", err)
|
||||
t.Skip("local LLM API health check failed - skipping integration test")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSupportedModels(t *testing.T) {
|
||||
tests := []struct {
|
||||
model string
|
||||
expected bool
|
||||
}{
|
||||
{"reasoning", true},
|
||||
{"ornith:35b", true},
|
||||
{"ornith:13b", true},
|
||||
{"qwen2.5:3b", true},
|
||||
{"unsupported-model", false},
|
||||
{"", false},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.model, func(t *testing.T) {
|
||||
if SupportedModels[tt.model] != tt.expected {
|
||||
t.Errorf("model %q: expected %v, got %v", tt.model, tt.expected, SupportedModels[tt.model])
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateMessageValidation(t *testing.T) {
|
||||
client, _ := NewClient()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
modelID string
|
||||
wantErr bool
|
||||
}{
|
||||
{"valid reasoning", "reasoning", true}, // Will fail to connect, but validates model
|
||||
{"valid ornith", "ornith:35b", true}, // Will fail to connect, but validates model
|
||||
{"invalid model", "invalid-model", false}, // Should fail validation
|
||||
{"empty model", "", false}, // Should fail validation
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
in := MessageInput{
|
||||
Model: statemachine.ModelSpec{
|
||||
ModelID: tt.modelID,
|
||||
},
|
||||
SystemPrompt: "test",
|
||||
Messages: []MessageParam{
|
||||
{Role: "user", Content: "test"},
|
||||
},
|
||||
}
|
||||
|
||||
_, err := client.CreateMessage(context.Background(), in)
|
||||
|
||||
hasErr := err != nil
|
||||
if hasErr != tt.wantErr {
|
||||
if tt.wantErr {
|
||||
t.Logf("expected error for model %q (likely API not reachable): %v", tt.modelID, err)
|
||||
} else if !hasErr {
|
||||
t.Errorf("expected error for invalid model %q, but got none", tt.modelID)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLocalLLMBaseURL(t *testing.T) {
|
||||
if LocalLLMBaseURL != "https://api.riotpiao.com" {
|
||||
t.Errorf("expected base URL https://api.riotpiao.com, got %s", LocalLLMBaseURL)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user