- Add JIRA, Mattermost, Plane adapter implementations - Add Mattermost client tests - Update core server setup and main.go - Improve config and validation tests - Enhance HTTP handlers and middleware tests - Update work item provider and notification tests - Add protoSocket tasks tests - Update agent-task and agent-roadmap documentation
158 lines
4.9 KiB
Go
158 lines
4.9 KiB
Go
package config
|
|
|
|
import "testing"
|
|
|
|
func TestLoadA2AEdgeURLPrefersEdgeURL(t *testing.T) {
|
|
t.Setenv("A2A_EDGE_URL", "http://edge.example/a2a")
|
|
t.Setenv("A2A_AGENT_URL", "http://legacy.example/a2a")
|
|
|
|
cfg := Load()
|
|
|
|
if cfg.A2AEdgeURL != "http://edge.example/a2a" {
|
|
t.Fatalf("A2AEdgeURL: got %q", cfg.A2AEdgeURL)
|
|
}
|
|
if cfg.A2AAgentURL != "http://legacy.example/a2a" {
|
|
t.Fatalf("A2AAgentURL: got %q", cfg.A2AAgentURL)
|
|
}
|
|
}
|
|
|
|
func TestLoadA2AEdgeURLFallsBackToLegacyAgentURL(t *testing.T) {
|
|
t.Setenv("A2A_AGENT_URL", "http://legacy.example/a2a")
|
|
|
|
cfg := Load()
|
|
|
|
if cfg.A2AEdgeURL != "http://legacy.example/a2a" {
|
|
t.Fatalf("A2AEdgeURL fallback: got %q", cfg.A2AEdgeURL)
|
|
}
|
|
if cfg.A2AAgentURL != "http://legacy.example/a2a" {
|
|
t.Fatalf("A2AAgentURL: got %q", cfg.A2AAgentURL)
|
|
}
|
|
}
|
|
|
|
func TestLoadModelAndA2ADefaults(t *testing.T) {
|
|
cfg := Load()
|
|
|
|
if cfg.ModelBaseURL != "http://192.168.0.91:11434" {
|
|
t.Fatalf("ModelBaseURL: got %q", cfg.ModelBaseURL)
|
|
}
|
|
if cfg.ModelAPIKey != "ollama" {
|
|
t.Fatalf("ModelAPIKey: got %q", cfg.ModelAPIKey)
|
|
}
|
|
if cfg.ModelName != "qwen3.6:35b-a3b-bf16" {
|
|
t.Fatalf("ModelName: got %q", cfg.ModelName)
|
|
}
|
|
if cfg.ModelContextSize != 262144 {
|
|
t.Fatalf("ModelContextSize: got %d", cfg.ModelContextSize)
|
|
}
|
|
if cfg.ModelTimeoutSec != 300 {
|
|
t.Fatalf("ModelTimeoutSec: got %d", cfg.ModelTimeoutSec)
|
|
}
|
|
if cfg.A2ATimeoutSec != 300 {
|
|
t.Fatalf("A2ATimeoutSec: got %d", cfg.A2ATimeoutSec)
|
|
}
|
|
}
|
|
|
|
func TestConfigLoadsWorkflowTaskTimeout(t *testing.T) {
|
|
cfg := Load()
|
|
if cfg.WorkflowTaskTimeoutSec != 300 {
|
|
t.Fatalf("WorkflowTaskTimeoutSec default: got %d, want 300", cfg.WorkflowTaskTimeoutSec)
|
|
}
|
|
|
|
t.Setenv("WORKFLOW_TASK_TIMEOUT_SEC", "120")
|
|
cfgOverride := Load()
|
|
if cfgOverride.WorkflowTaskTimeoutSec != 120 {
|
|
t.Fatalf("WorkflowTaskTimeoutSec override: got %d, want 120", cfgOverride.WorkflowTaskTimeoutSec)
|
|
}
|
|
}
|
|
|
|
func TestConfigLoadsProtoSocketDefaultsAndOverrides(t *testing.T) {
|
|
cfg := Load()
|
|
if cfg.ProtoSocketPath != "/proto-socket" {
|
|
t.Fatalf("ProtoSocketPath default: got %q, want %q", cfg.ProtoSocketPath, "/proto-socket")
|
|
}
|
|
if cfg.ProtoSocketHeartbeatIntervalSec != 30 {
|
|
t.Fatalf("ProtoSocketHeartbeatIntervalSec default: got %d, want 30", cfg.ProtoSocketHeartbeatIntervalSec)
|
|
}
|
|
if cfg.ProtoSocketHeartbeatWaitSec != 10 {
|
|
t.Fatalf("ProtoSocketHeartbeatWaitSec default: got %d, want 10", cfg.ProtoSocketHeartbeatWaitSec)
|
|
}
|
|
|
|
t.Setenv("PROTO_SOCKET_PATH", "/custom-path")
|
|
t.Setenv("PROTO_SOCKET_HEARTBEAT_INTERVAL_SEC", "15")
|
|
t.Setenv("PROTO_SOCKET_HEARTBEAT_WAIT_SEC", "5")
|
|
|
|
cfgOverride := Load()
|
|
if cfgOverride.ProtoSocketPath != "/custom-path" {
|
|
t.Fatalf("ProtoSocketPath override: got %q, want %q", cfgOverride.ProtoSocketPath, "/custom-path")
|
|
}
|
|
if cfgOverride.ProtoSocketHeartbeatIntervalSec != 15 {
|
|
t.Fatalf("ProtoSocketHeartbeatIntervalSec override: got %d, want 15", cfgOverride.ProtoSocketHeartbeatIntervalSec)
|
|
}
|
|
if cfgOverride.ProtoSocketHeartbeatWaitSec != 5 {
|
|
t.Fatalf("ProtoSocketHeartbeatWaitSec override: got %d, want 5", cfgOverride.ProtoSocketHeartbeatWaitSec)
|
|
}
|
|
}
|
|
|
|
func TestConfigLoadsJiraEnvVars(t *testing.T) {
|
|
t.Setenv("JIRA_BASE_URL", "https://jira.example.com")
|
|
t.Setenv("JIRA_EMAIL", "user@example.com")
|
|
t.Setenv("JIRA_API_TOKEN", "api-token-123")
|
|
|
|
cfg := Load()
|
|
|
|
if cfg.JiraBaseURL != "https://jira.example.com" {
|
|
t.Fatalf("JiraBaseURL: got %q", cfg.JiraBaseURL)
|
|
}
|
|
if cfg.JiraEmail != "user@example.com" {
|
|
t.Fatalf("JiraEmail: got %q", cfg.JiraEmail)
|
|
}
|
|
if cfg.JiraAPIToken != "api-token-123" {
|
|
t.Fatalf("JiraAPIToken: got %q", cfg.JiraAPIToken)
|
|
}
|
|
}
|
|
|
|
func TestConfigLoadsMattermostEnvVars(t *testing.T) {
|
|
t.Setenv("MATTERMOST_BASE_URL", "https://mattermost.example.com")
|
|
t.Setenv("MATTERMOST_TOKEN", "mattermost-token")
|
|
t.Setenv("MATTERMOST_CHANNEL_ID", "channel-id")
|
|
|
|
cfg := Load()
|
|
|
|
if cfg.MattermostBaseURL != "https://mattermost.example.com" {
|
|
t.Fatalf("MattermostBaseURL: got %q", cfg.MattermostBaseURL)
|
|
}
|
|
if cfg.MattermostToken != "mattermost-token" {
|
|
t.Fatalf("MattermostToken: got %q", cfg.MattermostToken)
|
|
}
|
|
if cfg.MattermostChannelID != "channel-id" {
|
|
t.Fatalf("MattermostChannelID: got %q", cfg.MattermostChannelID)
|
|
}
|
|
}
|
|
|
|
func TestConfigMattermostFieldsAreEmptyByDefault(t *testing.T) {
|
|
cfg := Load()
|
|
|
|
if cfg.MattermostBaseURL != "" {
|
|
t.Fatalf("MattermostBaseURL default: got %q, want empty", cfg.MattermostBaseURL)
|
|
}
|
|
if cfg.MattermostToken != "" {
|
|
t.Fatalf("MattermostToken default: got %q, want empty", cfg.MattermostToken)
|
|
}
|
|
if cfg.MattermostChannelID != "" {
|
|
t.Fatalf("MattermostChannelID default: got %q, want empty", cfg.MattermostChannelID)
|
|
}
|
|
}
|
|
|
|
func TestConfigJiraFieldsAreEmptyByDefault(t *testing.T) {
|
|
cfg := Load()
|
|
|
|
if cfg.JiraBaseURL != "" {
|
|
t.Fatalf("JiraBaseURL default: got %q, want empty", cfg.JiraBaseURL)
|
|
}
|
|
if cfg.JiraEmail != "" {
|
|
t.Fatalf("JiraEmail default: got %q, want empty", cfg.JiraEmail)
|
|
}
|
|
if cfg.JiraAPIToken != "" {
|
|
t.Fatalf("JiraAPIToken default: got %q, want empty", cfg.JiraAPIToken)
|
|
}
|
|
}
|