test: 413 new tests — agentic 54.3%, setup 75.8%, all packages passing
Coverage: agentic 40.1% → 54.3%, setup 71.5% → 75.8%
Total: 695 passing tests across all packages (was ~357)
New test files (15):
- commands_forge_test.go — parseForgeArgs, fmtIndex
- commands_workspace_test.go — extractField (9 cases)
- commands_test.go — command registration + Core integration
- handlers_test.go — RegisterHandlers, IPC pipeline, lifecycle
- plan_crud_test.go — full CRUD via MCP handlers (23 tests)
- prep_extra_test.go — buildPrompt, findConsumersList, pullWikiContent, getIssueBody
- queue_extra_test.go — ConcurrencyLimit YAML, delayForAgent, drainOne
- remote_client_test.go — mcpInitialize, mcpCall, readSSEData, setHeaders
- remote_test.go — resolveHost, remoteToken
- resume_test.go — resume dry run, agent override, validation
- review_queue_test.go — countFindings, parseRetryAfter, buildAutoPRBody
- review_queue_extra_test.go — buildReviewCommand, rateLimitState, reviewQueue
- verify_extra_test.go — attemptVerifyAndMerge, autoVerifyAndMerge pipeline
- watch_test.go — findActiveWorkspaces, resolveWorkspaceDir
- setup/setup_extra_test.go — defaultBuildCommand, defaultTestCommand all branches
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:44:17 +00:00
|
|
|
// SPDX-License-Identifier: EUPL-1.2
|
|
|
|
|
|
|
|
|
|
package agentic
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// --- resolveHost (extended — base cases are in paths_test.go) ---
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestRemote_ResolveHost_Good_CaseInsensitive(t *testing.T) {
|
test: 413 new tests — agentic 54.3%, setup 75.8%, all packages passing
Coverage: agentic 40.1% → 54.3%, setup 71.5% → 75.8%
Total: 695 passing tests across all packages (was ~357)
New test files (15):
- commands_forge_test.go — parseForgeArgs, fmtIndex
- commands_workspace_test.go — extractField (9 cases)
- commands_test.go — command registration + Core integration
- handlers_test.go — RegisterHandlers, IPC pipeline, lifecycle
- plan_crud_test.go — full CRUD via MCP handlers (23 tests)
- prep_extra_test.go — buildPrompt, findConsumersList, pullWikiContent, getIssueBody
- queue_extra_test.go — ConcurrencyLimit YAML, delayForAgent, drainOne
- remote_client_test.go — mcpInitialize, mcpCall, readSSEData, setHeaders
- remote_test.go — resolveHost, remoteToken
- resume_test.go — resume dry run, agent override, validation
- review_queue_test.go — countFindings, parseRetryAfter, buildAutoPRBody
- review_queue_extra_test.go — buildReviewCommand, rateLimitState, reviewQueue
- verify_extra_test.go — attemptVerifyAndMerge, autoVerifyAndMerge pipeline
- watch_test.go — findActiveWorkspaces, resolveWorkspaceDir
- setup/setup_extra_test.go — defaultBuildCommand, defaultTestCommand all branches
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:44:17 +00:00
|
|
|
assert.Equal(t, "10.69.69.165:9101", resolveHost("Charon"))
|
|
|
|
|
assert.Equal(t, "10.69.69.165:9101", resolveHost("CHARON"))
|
|
|
|
|
assert.Equal(t, "127.0.0.1:9101", resolveHost("Cladius"))
|
|
|
|
|
assert.Equal(t, "127.0.0.1:9101", resolveHost("LOCAL"))
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestRemote_ResolveHost_Good_CustomHost(t *testing.T) {
|
test: 413 new tests — agentic 54.3%, setup 75.8%, all packages passing
Coverage: agentic 40.1% → 54.3%, setup 71.5% → 75.8%
Total: 695 passing tests across all packages (was ~357)
New test files (15):
- commands_forge_test.go — parseForgeArgs, fmtIndex
- commands_workspace_test.go — extractField (9 cases)
- commands_test.go — command registration + Core integration
- handlers_test.go — RegisterHandlers, IPC pipeline, lifecycle
- plan_crud_test.go — full CRUD via MCP handlers (23 tests)
- prep_extra_test.go — buildPrompt, findConsumersList, pullWikiContent, getIssueBody
- queue_extra_test.go — ConcurrencyLimit YAML, delayForAgent, drainOne
- remote_client_test.go — mcpInitialize, mcpCall, readSSEData, setHeaders
- remote_test.go — resolveHost, remoteToken
- resume_test.go — resume dry run, agent override, validation
- review_queue_test.go — countFindings, parseRetryAfter, buildAutoPRBody
- review_queue_extra_test.go — buildReviewCommand, rateLimitState, reviewQueue
- verify_extra_test.go — attemptVerifyAndMerge, autoVerifyAndMerge pipeline
- watch_test.go — findActiveWorkspaces, resolveWorkspaceDir
- setup/setup_extra_test.go — defaultBuildCommand, defaultTestCommand all branches
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:44:17 +00:00
|
|
|
assert.Equal(t, "my-server:9101", resolveHost("my-server"))
|
|
|
|
|
assert.Equal(t, "192.168.1.100:8080", resolveHost("192.168.1.100:8080"))
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-02 09:12:49 +00:00
|
|
|
func TestRemote_ResolveHost_Good_TrimmedInput(t *testing.T) {
|
|
|
|
|
assert.Equal(t, "10.69.69.165:9101", resolveHost(" charon "))
|
|
|
|
|
assert.Equal(t, "my-server:9101", resolveHost(" my-server "))
|
|
|
|
|
}
|
|
|
|
|
|
test: 413 new tests — agentic 54.3%, setup 75.8%, all packages passing
Coverage: agentic 40.1% → 54.3%, setup 71.5% → 75.8%
Total: 695 passing tests across all packages (was ~357)
New test files (15):
- commands_forge_test.go — parseForgeArgs, fmtIndex
- commands_workspace_test.go — extractField (9 cases)
- commands_test.go — command registration + Core integration
- handlers_test.go — RegisterHandlers, IPC pipeline, lifecycle
- plan_crud_test.go — full CRUD via MCP handlers (23 tests)
- prep_extra_test.go — buildPrompt, findConsumersList, pullWikiContent, getIssueBody
- queue_extra_test.go — ConcurrencyLimit YAML, delayForAgent, drainOne
- remote_client_test.go — mcpInitialize, mcpCall, readSSEData, setHeaders
- remote_test.go — resolveHost, remoteToken
- resume_test.go — resume dry run, agent override, validation
- review_queue_test.go — countFindings, parseRetryAfter, buildAutoPRBody
- review_queue_extra_test.go — buildReviewCommand, rateLimitState, reviewQueue
- verify_extra_test.go — attemptVerifyAndMerge, autoVerifyAndMerge pipeline
- watch_test.go — findActiveWorkspaces, resolveWorkspaceDir
- setup/setup_extra_test.go — defaultBuildCommand, defaultTestCommand all branches
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:44:17 +00:00
|
|
|
// --- remoteToken ---
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestRemote_RemoteToken_Good_FromEnv(t *testing.T) {
|
test: 413 new tests — agentic 54.3%, setup 75.8%, all packages passing
Coverage: agentic 40.1% → 54.3%, setup 71.5% → 75.8%
Total: 695 passing tests across all packages (was ~357)
New test files (15):
- commands_forge_test.go — parseForgeArgs, fmtIndex
- commands_workspace_test.go — extractField (9 cases)
- commands_test.go — command registration + Core integration
- handlers_test.go — RegisterHandlers, IPC pipeline, lifecycle
- plan_crud_test.go — full CRUD via MCP handlers (23 tests)
- prep_extra_test.go — buildPrompt, findConsumersList, pullWikiContent, getIssueBody
- queue_extra_test.go — ConcurrencyLimit YAML, delayForAgent, drainOne
- remote_client_test.go — mcpInitialize, mcpCall, readSSEData, setHeaders
- remote_test.go — resolveHost, remoteToken
- resume_test.go — resume dry run, agent override, validation
- review_queue_test.go — countFindings, parseRetryAfter, buildAutoPRBody
- review_queue_extra_test.go — buildReviewCommand, rateLimitState, reviewQueue
- verify_extra_test.go — attemptVerifyAndMerge, autoVerifyAndMerge pipeline
- watch_test.go — findActiveWorkspaces, resolveWorkspaceDir
- setup/setup_extra_test.go — defaultBuildCommand, defaultTestCommand all branches
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:44:17 +00:00
|
|
|
t.Setenv("AGENT_TOKEN_CHARON", "env-token-123")
|
|
|
|
|
token := remoteToken("CHARON")
|
|
|
|
|
assert.Equal(t, "env-token-123", token)
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestRemote_RemoteToken_Good_FallbackMCPAuth(t *testing.T) {
|
test: 413 new tests — agentic 54.3%, setup 75.8%, all packages passing
Coverage: agentic 40.1% → 54.3%, setup 71.5% → 75.8%
Total: 695 passing tests across all packages (was ~357)
New test files (15):
- commands_forge_test.go — parseForgeArgs, fmtIndex
- commands_workspace_test.go — extractField (9 cases)
- commands_test.go — command registration + Core integration
- handlers_test.go — RegisterHandlers, IPC pipeline, lifecycle
- plan_crud_test.go — full CRUD via MCP handlers (23 tests)
- prep_extra_test.go — buildPrompt, findConsumersList, pullWikiContent, getIssueBody
- queue_extra_test.go — ConcurrencyLimit YAML, delayForAgent, drainOne
- remote_client_test.go — mcpInitialize, mcpCall, readSSEData, setHeaders
- remote_test.go — resolveHost, remoteToken
- resume_test.go — resume dry run, agent override, validation
- review_queue_test.go — countFindings, parseRetryAfter, buildAutoPRBody
- review_queue_extra_test.go — buildReviewCommand, rateLimitState, reviewQueue
- verify_extra_test.go — attemptVerifyAndMerge, autoVerifyAndMerge pipeline
- watch_test.go — findActiveWorkspaces, resolveWorkspaceDir
- setup/setup_extra_test.go — defaultBuildCommand, defaultTestCommand all branches
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:44:17 +00:00
|
|
|
t.Setenv("AGENT_TOKEN_TOKENTEST", "")
|
|
|
|
|
t.Setenv("MCP_AUTH_TOKEN", "mcp-fallback")
|
|
|
|
|
token := remoteToken("tokentest")
|
|
|
|
|
assert.Equal(t, "mcp-fallback", token)
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestRemote_RemoteToken_Good_EnvPrecedence(t *testing.T) {
|
test: 413 new tests — agentic 54.3%, setup 75.8%, all packages passing
Coverage: agentic 40.1% → 54.3%, setup 71.5% → 75.8%
Total: 695 passing tests across all packages (was ~357)
New test files (15):
- commands_forge_test.go — parseForgeArgs, fmtIndex
- commands_workspace_test.go — extractField (9 cases)
- commands_test.go — command registration + Core integration
- handlers_test.go — RegisterHandlers, IPC pipeline, lifecycle
- plan_crud_test.go — full CRUD via MCP handlers (23 tests)
- prep_extra_test.go — buildPrompt, findConsumersList, pullWikiContent, getIssueBody
- queue_extra_test.go — ConcurrencyLimit YAML, delayForAgent, drainOne
- remote_client_test.go — mcpInitialize, mcpCall, readSSEData, setHeaders
- remote_test.go — resolveHost, remoteToken
- resume_test.go — resume dry run, agent override, validation
- review_queue_test.go — countFindings, parseRetryAfter, buildAutoPRBody
- review_queue_extra_test.go — buildReviewCommand, rateLimitState, reviewQueue
- verify_extra_test.go — attemptVerifyAndMerge, autoVerifyAndMerge pipeline
- watch_test.go — findActiveWorkspaces, resolveWorkspaceDir
- setup/setup_extra_test.go — defaultBuildCommand, defaultTestCommand all branches
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 00:44:17 +00:00
|
|
|
t.Setenv("AGENT_TOKEN_PRIO", "specific-token")
|
|
|
|
|
t.Setenv("MCP_AUTH_TOKEN", "generic-token")
|
|
|
|
|
token := remoteToken("PRIO")
|
|
|
|
|
assert.Equal(t, "specific-token", token, "host-specific env should take precedence")
|
|
|
|
|
}
|
2026-03-25 09:31:38 +00:00
|
|
|
|
2026-04-02 09:12:49 +00:00
|
|
|
func TestRemote_RemoteToken_Good_TrimmedInput(t *testing.T) {
|
|
|
|
|
t.Setenv("AGENT_TOKEN_CHARON", "trimmed-token")
|
|
|
|
|
token := remoteToken(" charon ")
|
|
|
|
|
assert.Equal(t, "trimmed-token", token)
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 09:31:38 +00:00
|
|
|
// --- resolveHost Bad/Ugly ---
|
|
|
|
|
|
|
|
|
|
func TestRemote_ResolveHost_Bad(t *testing.T) {
|
|
|
|
|
// Empty string — returns empty host with default port appended
|
|
|
|
|
result := resolveHost("")
|
|
|
|
|
assert.Equal(t, ":9101", result)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestRemote_ResolveHost_Ugly(t *testing.T) {
|
|
|
|
|
// Unicode host name — not an alias, no colon, so default port appended
|
|
|
|
|
result := resolveHost("\u00e9nchantr\u00efx")
|
|
|
|
|
assert.Equal(t, "\u00e9nchantr\u00efx:9101", result)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --- remoteToken Bad/Ugly ---
|
|
|
|
|
|
|
|
|
|
func TestRemote_RemoteToken_Bad(t *testing.T) {
|
|
|
|
|
// Host with no matching env var and no file — returns empty
|
|
|
|
|
t.Setenv("AGENT_TOKEN_NOHOST", "")
|
|
|
|
|
t.Setenv("MCP_AUTH_TOKEN", "")
|
|
|
|
|
t.Setenv("DIR_HOME", t.TempDir()) // no token files
|
|
|
|
|
token := remoteToken("nohost")
|
|
|
|
|
assert.Equal(t, "", token)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestRemote_RemoteToken_Ugly(t *testing.T) {
|
|
|
|
|
// Host name with dashes and dots — creates odd env key like AGENT_TOKEN_MY-HOST.LOCAL
|
|
|
|
|
// Env lookup will use the exact uppercased key
|
|
|
|
|
t.Setenv("AGENT_TOKEN_MY-HOST.LOCAL", "")
|
|
|
|
|
t.Setenv("MCP_AUTH_TOKEN", "")
|
|
|
|
|
t.Setenv("DIR_HOME", t.TempDir())
|
|
|
|
|
token := remoteToken("my-host.local")
|
|
|
|
|
assert.Equal(t, "", token)
|
|
|
|
|
}
|