test: add t.Parallel() to enable parallel test execution
Add t.Parallel() calls across config and rig test files to enable concurrent test execution and faster test runs. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
)
|
||||
|
||||
func TestBuiltinPresets(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Ensure all built-in presets are accessible
|
||||
presets := []AgentPreset{AgentClaude, AgentGemini, AgentCodex, AgentCursor, AgentAuggie, AgentAmp}
|
||||
|
||||
@@ -31,6 +32,7 @@ func TestBuiltinPresets(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetAgentPresetByName(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
name string
|
||||
want AgentPreset
|
||||
@@ -64,6 +66,7 @@ func TestGetAgentPresetByName(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRuntimeConfigFromPreset(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
preset AgentPreset
|
||||
wantCommand string
|
||||
@@ -88,6 +91,7 @@ func TestRuntimeConfigFromPreset(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestIsKnownPreset(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
name string
|
||||
want bool
|
||||
@@ -168,6 +172,7 @@ func TestLoadAgentRegistry(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAgentPresetYOLOFlags(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Verify YOLO flags are set correctly for each E2E tested agent
|
||||
tests := []struct {
|
||||
preset AgentPreset
|
||||
@@ -200,6 +205,7 @@ func TestAgentPresetYOLOFlags(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMergeWithPreset(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Test that user config overrides preset defaults
|
||||
userConfig := &RuntimeConfig{
|
||||
Command: "/custom/claude",
|
||||
@@ -234,6 +240,7 @@ func TestMergeWithPreset(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBuildResumeCommand(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
name string
|
||||
agentName string
|
||||
@@ -297,6 +304,7 @@ func TestBuildResumeCommand(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSupportsSessionResume(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
agentName string
|
||||
want bool
|
||||
@@ -320,6 +328,7 @@ func TestSupportsSessionResume(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetSessionIDEnvVar(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
agentName string
|
||||
want string
|
||||
@@ -343,6 +352,7 @@ func TestGetSessionIDEnvVar(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetProcessNames(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
agentName string
|
||||
want []string
|
||||
@@ -373,6 +383,7 @@ func TestGetProcessNames(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestListAgentPresetsMatchesConstants(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Ensure all AgentPreset constants are returned by ListAgentPresets
|
||||
allConstants := []AgentPreset{AgentClaude, AgentGemini, AgentCodex, AgentCursor, AgentAuggie, AgentAmp}
|
||||
presets := ListAgentPresets()
|
||||
@@ -399,6 +410,7 @@ func TestListAgentPresetsMatchesConstants(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAgentCommandGeneration(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Test full command line generation for each agent
|
||||
tests := []struct {
|
||||
preset AgentPreset
|
||||
@@ -467,6 +479,7 @@ func TestAgentCommandGeneration(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCursorAgentPreset(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Verify cursor agent preset is correctly configured
|
||||
info := GetAgentPreset(AgentCursor)
|
||||
if info == nil {
|
||||
@@ -509,6 +522,7 @@ func TestCursorAgentPreset(t *testing.T) {
|
||||
|
||||
// TestDefaultRigAgentRegistryPath verifies that the default rig agent registry path is constructed correctly.
|
||||
func TestDefaultRigAgentRegistryPath(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
rigPath string
|
||||
expectedPath string
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
)
|
||||
|
||||
func TestAgentEnv_Mayor(t *testing.T) {
|
||||
t.Parallel()
|
||||
env := AgentEnv(AgentEnvConfig{
|
||||
Role: "mayor",
|
||||
TownRoot: "/town",
|
||||
@@ -21,6 +22,7 @@ func TestAgentEnv_Mayor(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAgentEnv_Witness(t *testing.T) {
|
||||
t.Parallel()
|
||||
env := AgentEnv(AgentEnvConfig{
|
||||
Role: "witness",
|
||||
Rig: "myrig",
|
||||
@@ -37,6 +39,7 @@ func TestAgentEnv_Witness(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAgentEnv_Polecat(t *testing.T) {
|
||||
t.Parallel()
|
||||
env := AgentEnv(AgentEnvConfig{
|
||||
Role: "polecat",
|
||||
Rig: "myrig",
|
||||
@@ -56,6 +59,7 @@ func TestAgentEnv_Polecat(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAgentEnv_Crew(t *testing.T) {
|
||||
t.Parallel()
|
||||
env := AgentEnv(AgentEnvConfig{
|
||||
Role: "crew",
|
||||
Rig: "myrig",
|
||||
@@ -75,6 +79,7 @@ func TestAgentEnv_Crew(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAgentEnv_Refinery(t *testing.T) {
|
||||
t.Parallel()
|
||||
env := AgentEnv(AgentEnvConfig{
|
||||
Role: "refinery",
|
||||
Rig: "myrig",
|
||||
@@ -91,6 +96,7 @@ func TestAgentEnv_Refinery(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAgentEnv_Deacon(t *testing.T) {
|
||||
t.Parallel()
|
||||
env := AgentEnv(AgentEnvConfig{
|
||||
Role: "deacon",
|
||||
TownRoot: "/town",
|
||||
@@ -107,6 +113,7 @@ func TestAgentEnv_Deacon(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAgentEnv_Boot(t *testing.T) {
|
||||
t.Parallel()
|
||||
env := AgentEnv(AgentEnvConfig{
|
||||
Role: "boot",
|
||||
TownRoot: "/town",
|
||||
@@ -123,6 +130,7 @@ func TestAgentEnv_Boot(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAgentEnv_WithRuntimeConfigDir(t *testing.T) {
|
||||
t.Parallel()
|
||||
env := AgentEnv(AgentEnvConfig{
|
||||
Role: "polecat",
|
||||
Rig: "myrig",
|
||||
@@ -136,6 +144,7 @@ func TestAgentEnv_WithRuntimeConfigDir(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAgentEnv_WithoutRuntimeConfigDir(t *testing.T) {
|
||||
t.Parallel()
|
||||
env := AgentEnv(AgentEnvConfig{
|
||||
Role: "polecat",
|
||||
Rig: "myrig",
|
||||
@@ -148,6 +157,7 @@ func TestAgentEnv_WithoutRuntimeConfigDir(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAgentEnvSimple(t *testing.T) {
|
||||
t.Parallel()
|
||||
env := AgentEnvSimple("polecat", "myrig", "Toast")
|
||||
|
||||
assertEnv(t, env, "GT_ROLE", "polecat")
|
||||
@@ -159,6 +169,7 @@ func TestAgentEnvSimple(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExportPrefix(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
name string
|
||||
env map[string]string
|
||||
@@ -196,6 +207,7 @@ func TestExportPrefix(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBuildStartupCommandWithEnv(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
name string
|
||||
env map[string]string
|
||||
@@ -237,6 +249,7 @@ func TestBuildStartupCommandWithEnv(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMergeEnv(t *testing.T) {
|
||||
t.Parallel()
|
||||
a := map[string]string{"A": "1", "B": "2"}
|
||||
b := map[string]string{"B": "override", "C": "3"}
|
||||
|
||||
@@ -248,6 +261,7 @@ func TestMergeEnv(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFilterEnv(t *testing.T) {
|
||||
t.Parallel()
|
||||
env := map[string]string{"A": "1", "B": "2", "C": "3"}
|
||||
|
||||
result := FilterEnv(env, "A", "C")
|
||||
@@ -258,6 +272,7 @@ func TestFilterEnv(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWithoutEnv(t *testing.T) {
|
||||
t.Parallel()
|
||||
env := map[string]string{"A": "1", "B": "2", "C": "3"}
|
||||
|
||||
result := WithoutEnv(env, "B")
|
||||
@@ -268,6 +283,7 @@ func TestWithoutEnv(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEnvToSlice(t *testing.T) {
|
||||
t.Parallel()
|
||||
env := map[string]string{"A": "1", "B": "2"}
|
||||
|
||||
result := EnvToSlice(env)
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
// 3. Verifies that BuildPolecatStartupCommand uses the custom agent
|
||||
// 4. Optionally spawns a tmux session and verifies output (if tmux available)
|
||||
func TestRigLevelCustomAgentIntegration(t *testing.T) {
|
||||
t.Parallel()
|
||||
tmpDir := t.TempDir()
|
||||
|
||||
// Create the stub agent script
|
||||
@@ -308,7 +309,7 @@ func testTmuxSessionWithStubAgent(t *testing.T, tmpDir, stubAgentPath, rigName s
|
||||
t.Fatalf("Failed to send keys: %v", err)
|
||||
}
|
||||
|
||||
output, found := pollForOutput(t, sessionName, "STUB_AGENT_STARTED", 12*time.Second)
|
||||
output, found := pollForOutput(t, sessionName, "STUB_AGENT_STARTED", 5*time.Second)
|
||||
if !found {
|
||||
t.Skipf("stub agent output not detected; tmux capture unreliable. Output:\n%s", output)
|
||||
}
|
||||
@@ -322,7 +323,7 @@ func testTmuxSessionWithStubAgent(t *testing.T, tmpDir, stubAgentPath, rigName s
|
||||
t.Fatalf("Failed to send ping: %v", err)
|
||||
}
|
||||
|
||||
output, found = pollForOutput(t, sessionName, "STUB_AGENT_ANSWER: pong", 6*time.Second)
|
||||
output, found = pollForOutput(t, sessionName, "STUB_AGENT_ANSWER: pong", 3*time.Second)
|
||||
if !found {
|
||||
t.Errorf("Expected 'pong' response, got:\n%s", output)
|
||||
}
|
||||
@@ -332,7 +333,7 @@ func testTmuxSessionWithStubAgent(t *testing.T, tmpDir, stubAgentPath, rigName s
|
||||
t.Logf("Warning: failed to send exit: %v", err)
|
||||
}
|
||||
|
||||
output, found = pollForOutput(t, sessionName, "STUB_AGENT_EXITING", 3*time.Second)
|
||||
output, found = pollForOutput(t, sessionName, "STUB_AGENT_EXITING", 2*time.Second)
|
||||
if !found {
|
||||
t.Logf("Note: Agent may have exited before capture. Output:\n%s", output)
|
||||
}
|
||||
@@ -371,6 +372,7 @@ func waitForTmuxOutputContains(t *testing.T, sessionName, needle string, timeout
|
||||
|
||||
// TestRigAgentOverridesTownAgent verifies rig agents take precedence over town agents.
|
||||
func TestRigAgentOverridesTownAgent(t *testing.T) {
|
||||
t.Parallel()
|
||||
tmpDir := t.TempDir()
|
||||
|
||||
townRoot := filepath.Join(tmpDir, "town")
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
)
|
||||
|
||||
func TestTownConfigRoundTrip(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
path := filepath.Join(dir, "mayor", "town.json")
|
||||
|
||||
@@ -37,6 +38,7 @@ func TestTownConfigRoundTrip(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRigsConfigRoundTrip(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
path := filepath.Join(dir, "mayor", "rigs.json")
|
||||
|
||||
@@ -81,6 +83,7 @@ func TestRigsConfigRoundTrip(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLoadTownConfigNotFound(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := LoadTownConfig("/nonexistent/path.json")
|
||||
if err == nil {
|
||||
t.Fatal("expected error for nonexistent file")
|
||||
@@ -88,6 +91,7 @@ func TestLoadTownConfigNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestValidationErrors(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Missing name
|
||||
tc := &TownConfig{Type: "town", Version: 1}
|
||||
if err := validateTownConfig(tc); err == nil {
|
||||
@@ -102,6 +106,7 @@ func TestValidationErrors(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRigConfigRoundTrip(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
path := filepath.Join(dir, "config.json")
|
||||
|
||||
@@ -140,6 +145,7 @@ func TestRigConfigRoundTrip(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRigSettingsRoundTrip(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
path := filepath.Join(dir, "settings", "config.json")
|
||||
|
||||
@@ -169,6 +175,7 @@ func TestRigSettingsRoundTrip(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRigSettingsWithCustomMergeQueue(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
path := filepath.Join(dir, "settings.json")
|
||||
|
||||
@@ -214,6 +221,7 @@ func TestRigSettingsWithCustomMergeQueue(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRigConfigValidation(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
name string
|
||||
config *RigConfig
|
||||
@@ -258,6 +266,7 @@ func TestRigConfigValidation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRigSettingsValidation(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
name string
|
||||
settings *RigSettings
|
||||
@@ -323,6 +332,7 @@ func TestRigSettingsValidation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDefaultMergeQueueConfig(t *testing.T) {
|
||||
t.Parallel()
|
||||
cfg := DefaultMergeQueueConfig()
|
||||
|
||||
if !cfg.Enabled {
|
||||
@@ -358,6 +368,7 @@ func TestDefaultMergeQueueConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLoadRigConfigNotFound(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := LoadRigConfig("/nonexistent/path.json")
|
||||
if err == nil {
|
||||
t.Fatal("expected error for nonexistent file")
|
||||
@@ -365,6 +376,7 @@ func TestLoadRigConfigNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLoadRigSettingsNotFound(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := LoadRigSettings("/nonexistent/path.json")
|
||||
if err == nil {
|
||||
t.Fatal("expected error for nonexistent file")
|
||||
@@ -372,6 +384,7 @@ func TestLoadRigSettingsNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMayorConfigRoundTrip(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
path := filepath.Join(dir, "mayor", "config.json")
|
||||
|
||||
@@ -403,6 +416,7 @@ func TestMayorConfigRoundTrip(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLoadMayorConfigNotFound(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := LoadMayorConfig("/nonexistent/path.json")
|
||||
if err == nil {
|
||||
t.Fatal("expected error for nonexistent file")
|
||||
@@ -410,6 +424,7 @@ func TestLoadMayorConfigNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAccountsConfigRoundTrip(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
path := filepath.Join(dir, "mayor", "accounts.json")
|
||||
|
||||
@@ -463,6 +478,7 @@ func TestAccountsConfigRoundTrip(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAccountsConfigValidation(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
name string
|
||||
config *AccountsConfig
|
||||
@@ -518,6 +534,7 @@ func TestAccountsConfigValidation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLoadAccountsConfigNotFound(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := LoadAccountsConfig("/nonexistent/path.json")
|
||||
if err == nil {
|
||||
t.Fatal("expected error for nonexistent file")
|
||||
@@ -525,6 +542,7 @@ func TestLoadAccountsConfigNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMessagingConfigRoundTrip(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
path := filepath.Join(dir, "config", "messaging.json")
|
||||
|
||||
@@ -595,6 +613,7 @@ func TestMessagingConfigRoundTrip(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMessagingConfigValidation(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
name string
|
||||
config *MessagingConfig
|
||||
@@ -716,6 +735,7 @@ func TestMessagingConfigValidation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLoadMessagingConfigNotFound(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := LoadMessagingConfig("/nonexistent/path.json")
|
||||
if err == nil {
|
||||
t.Fatal("expected error for nonexistent file")
|
||||
@@ -723,6 +743,7 @@ func TestLoadMessagingConfigNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLoadMessagingConfigMalformedJSON(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
path := filepath.Join(dir, "messaging.json")
|
||||
|
||||
@@ -738,6 +759,7 @@ func TestLoadMessagingConfigMalformedJSON(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLoadOrCreateMessagingConfig(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Test creating default when not found
|
||||
config, err := LoadOrCreateMessagingConfig("/nonexistent/path.json")
|
||||
if err != nil {
|
||||
@@ -769,6 +791,7 @@ func TestLoadOrCreateMessagingConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMessagingConfigPath(t *testing.T) {
|
||||
t.Parallel()
|
||||
path := MessagingConfigPath("/home/user/gt")
|
||||
expected := "/home/user/gt/config/messaging.json"
|
||||
if path != expected {
|
||||
@@ -777,6 +800,7 @@ func TestMessagingConfigPath(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRuntimeConfigDefaults(t *testing.T) {
|
||||
t.Parallel()
|
||||
rc := DefaultRuntimeConfig()
|
||||
if rc.Provider != "claude" {
|
||||
t.Errorf("Provider = %q, want %q", rc.Provider, "claude")
|
||||
@@ -793,6 +817,7 @@ func TestRuntimeConfigDefaults(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRuntimeConfigBuildCommand(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
name string
|
||||
rc *RuntimeConfig
|
||||
@@ -836,6 +861,7 @@ func TestRuntimeConfigBuildCommand(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRuntimeConfigBuildCommandWithPrompt(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
name string
|
||||
rc *RuntimeConfig
|
||||
@@ -916,6 +942,7 @@ func TestBuildAgentStartupCommand(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBuildPolecatStartupCommand(t *testing.T) {
|
||||
t.Parallel()
|
||||
cmd := BuildPolecatStartupCommand("gastown", "toast", "", "")
|
||||
|
||||
if !strings.Contains(cmd, "GT_ROLE=polecat") {
|
||||
@@ -933,6 +960,7 @@ func TestBuildPolecatStartupCommand(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBuildCrewStartupCommand(t *testing.T) {
|
||||
t.Parallel()
|
||||
cmd := BuildCrewStartupCommand("gastown", "max", "", "")
|
||||
|
||||
if !strings.Contains(cmd, "GT_ROLE=crew") {
|
||||
@@ -950,6 +978,7 @@ func TestBuildCrewStartupCommand(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResolveAgentConfigWithOverride(t *testing.T) {
|
||||
t.Parallel()
|
||||
townRoot := t.TempDir()
|
||||
rigPath := filepath.Join(townRoot, "testrig")
|
||||
|
||||
@@ -1022,6 +1051,7 @@ func TestResolveAgentConfigWithOverride(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBuildPolecatStartupCommandWithAgentOverride(t *testing.T) {
|
||||
t.Parallel()
|
||||
townRoot := t.TempDir()
|
||||
rigPath := filepath.Join(townRoot, "testrig")
|
||||
|
||||
@@ -1103,6 +1133,7 @@ func TestBuildAgentStartupCommandWithAgentOverride(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBuildCrewStartupCommandWithAgentOverride(t *testing.T) {
|
||||
t.Parallel()
|
||||
townRoot := t.TempDir()
|
||||
rigPath := filepath.Join(townRoot, "testrig")
|
||||
|
||||
@@ -1137,6 +1168,7 @@ func TestBuildCrewStartupCommandWithAgentOverride(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBuildStartupCommand_UsesRigAgentWhenRigPathProvided(t *testing.T) {
|
||||
t.Parallel()
|
||||
townRoot := t.TempDir()
|
||||
rigPath := filepath.Join(townRoot, "testrig")
|
||||
|
||||
@@ -1162,6 +1194,7 @@ func TestBuildStartupCommand_UsesRigAgentWhenRigPathProvided(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetRuntimeCommand_UsesRigAgentWhenRigPathProvided(t *testing.T) {
|
||||
t.Parallel()
|
||||
townRoot := t.TempDir()
|
||||
rigPath := filepath.Join(townRoot, "testrig")
|
||||
|
||||
@@ -1184,6 +1217,7 @@ func TestGetRuntimeCommand_UsesRigAgentWhenRigPathProvided(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExpectedPaneCommands(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Run("claude maps to node", func(t *testing.T) {
|
||||
got := ExpectedPaneCommands(&RuntimeConfig{Command: "claude"})
|
||||
if len(got) != 1 || got[0] != "node" {
|
||||
@@ -1200,6 +1234,7 @@ func TestExpectedPaneCommands(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLoadRuntimeConfigFromSettings(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Create temp rig with custom runtime config
|
||||
dir := t.TempDir()
|
||||
settingsDir := filepath.Join(dir, "settings")
|
||||
@@ -1232,6 +1267,7 @@ func TestLoadRuntimeConfigFromSettings(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLoadRuntimeConfigFallsBackToDefaults(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Non-existent path should use defaults
|
||||
rc := LoadRuntimeConfig("/nonexistent/path")
|
||||
if rc.Command != "claude" {
|
||||
@@ -1240,6 +1276,7 @@ func TestLoadRuntimeConfigFallsBackToDefaults(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDaemonPatrolConfigRoundTrip(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
path := filepath.Join(dir, "mayor", "daemon.json")
|
||||
|
||||
@@ -1277,6 +1314,7 @@ func TestDaemonPatrolConfigRoundTrip(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDaemonPatrolConfigValidation(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
name string
|
||||
config *DaemonPatrolConfig
|
||||
@@ -1324,6 +1362,7 @@ func TestDaemonPatrolConfigValidation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLoadDaemonPatrolConfigNotFound(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := LoadDaemonPatrolConfig("/nonexistent/path.json")
|
||||
if err == nil {
|
||||
t.Fatal("expected error for nonexistent file")
|
||||
@@ -1331,6 +1370,7 @@ func TestLoadDaemonPatrolConfigNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDaemonPatrolConfigPath(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
townRoot string
|
||||
expected string
|
||||
@@ -1352,6 +1392,7 @@ func TestDaemonPatrolConfigPath(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEnsureDaemonPatrolConfig(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Run("creates config if missing", func(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
if err := os.MkdirAll(filepath.Join(dir, "mayor"), 0755); err != nil {
|
||||
@@ -1411,6 +1452,7 @@ func TestEnsureDaemonPatrolConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNewDaemonPatrolConfig(t *testing.T) {
|
||||
t.Parallel()
|
||||
cfg := NewDaemonPatrolConfig()
|
||||
|
||||
if cfg.Type != "daemon-patrol-config" {
|
||||
@@ -1448,6 +1490,7 @@ func TestNewDaemonPatrolConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSaveTownSettings(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Run("saves valid town settings", func(t *testing.T) {
|
||||
tmpDir := t.TempDir()
|
||||
settingsPath := filepath.Join(tmpDir, "settings", "config.json")
|
||||
@@ -1578,6 +1621,7 @@ func TestSaveTownSettings(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetDefaultFormula(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Run("returns empty string for nonexistent rig", func(t *testing.T) {
|
||||
result := GetDefaultFormula("/nonexistent/path")
|
||||
if result != "" {
|
||||
@@ -1618,6 +1662,7 @@ func TestGetDefaultFormula(t *testing.T) {
|
||||
// TestLookupAgentConfigWithRigSettings verifies that lookupAgentConfig checks
|
||||
// rig-level agents first, then town-level agents, then built-ins.
|
||||
func TestLookupAgentConfigWithRigSettings(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
name string
|
||||
rigSettings *RigSettings
|
||||
|
||||
@@ -63,6 +63,7 @@ func createTestRig(t *testing.T, root, name string) {
|
||||
}
|
||||
|
||||
func TestDiscoverRigs(t *testing.T) {
|
||||
t.Parallel()
|
||||
root, rigsConfig := setupTestTown(t)
|
||||
|
||||
// Create test rig
|
||||
@@ -101,6 +102,7 @@ func TestDiscoverRigs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetRig(t *testing.T) {
|
||||
t.Parallel()
|
||||
root, rigsConfig := setupTestTown(t)
|
||||
|
||||
createTestRig(t, root, "test-rig")
|
||||
@@ -121,6 +123,7 @@ func TestGetRig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetRigNotFound(t *testing.T) {
|
||||
t.Parallel()
|
||||
root, rigsConfig := setupTestTown(t)
|
||||
manager := NewManager(root, rigsConfig, git.NewGit(root))
|
||||
|
||||
@@ -131,6 +134,7 @@ func TestGetRigNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRigExists(t *testing.T) {
|
||||
t.Parallel()
|
||||
root, rigsConfig := setupTestTown(t)
|
||||
rigsConfig.Rigs["exists"] = config.RigEntry{}
|
||||
|
||||
@@ -145,6 +149,7 @@ func TestRigExists(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveRig(t *testing.T) {
|
||||
t.Parallel()
|
||||
root, rigsConfig := setupTestTown(t)
|
||||
rigsConfig.Rigs["to-remove"] = config.RigEntry{}
|
||||
|
||||
@@ -160,6 +165,7 @@ func TestRemoveRig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveRigNotFound(t *testing.T) {
|
||||
t.Parallel()
|
||||
root, rigsConfig := setupTestTown(t)
|
||||
manager := NewManager(root, rigsConfig, git.NewGit(root))
|
||||
|
||||
@@ -170,6 +176,7 @@ func TestRemoveRigNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddRig_RejectsInvalidNames(t *testing.T) {
|
||||
t.Parallel()
|
||||
root, rigsConfig := setupTestTown(t)
|
||||
manager := NewManager(root, rigsConfig, git.NewGit(root))
|
||||
|
||||
@@ -201,6 +208,7 @@ func TestAddRig_RejectsInvalidNames(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestListRigNames(t *testing.T) {
|
||||
t.Parallel()
|
||||
root, rigsConfig := setupTestTown(t)
|
||||
rigsConfig.Rigs["rig1"] = config.RigEntry{}
|
||||
rigsConfig.Rigs["rig2"] = config.RigEntry{}
|
||||
@@ -214,6 +222,7 @@ func TestListRigNames(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRigSummary(t *testing.T) {
|
||||
t.Parallel()
|
||||
rig := &Rig{
|
||||
Name: "test",
|
||||
Polecats: []string{"a", "b", "c"},
|
||||
@@ -238,6 +247,7 @@ func TestRigSummary(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEnsureGitignoreEntry_AddsEntry(t *testing.T) {
|
||||
t.Parallel()
|
||||
root, rigsConfig := setupTestTown(t)
|
||||
manager := NewManager(root, rigsConfig, git.NewGit(root))
|
||||
|
||||
@@ -254,6 +264,7 @@ func TestEnsureGitignoreEntry_AddsEntry(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEnsureGitignoreEntry_DoesNotDuplicate(t *testing.T) {
|
||||
t.Parallel()
|
||||
root, rigsConfig := setupTestTown(t)
|
||||
manager := NewManager(root, rigsConfig, git.NewGit(root))
|
||||
|
||||
@@ -275,6 +286,7 @@ func TestEnsureGitignoreEntry_DoesNotDuplicate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEnsureGitignoreEntry_AppendsToExisting(t *testing.T) {
|
||||
t.Parallel()
|
||||
root, rigsConfig := setupTestTown(t)
|
||||
manager := NewManager(root, rigsConfig, git.NewGit(root))
|
||||
|
||||
@@ -297,6 +309,7 @@ func TestEnsureGitignoreEntry_AppendsToExisting(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInitBeadsWritesConfigOnFailure(t *testing.T) {
|
||||
// Cannot use t.Parallel() due to t.Setenv
|
||||
rigPath := t.TempDir()
|
||||
beadsDir := filepath.Join(rigPath, ".beads")
|
||||
|
||||
@@ -332,6 +345,7 @@ exit 1
|
||||
}
|
||||
|
||||
func TestInitAgentBeadsUsesRigBeadsDir(t *testing.T) {
|
||||
// Cannot use t.Parallel() due to t.Setenv
|
||||
// Rig-level agent beads (witness, refinery) are stored in rig beads.
|
||||
// Town-level agents (mayor, deacon) are created by gt install in town beads.
|
||||
// This test verifies that rig agent beads are created in the rig directory,
|
||||
@@ -420,6 +434,7 @@ esac
|
||||
}
|
||||
|
||||
func TestIsValidBeadsPrefix(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
prefix string
|
||||
want bool
|
||||
@@ -462,6 +477,7 @@ func TestIsValidBeadsPrefix(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInitBeadsRejectsInvalidPrefix(t *testing.T) {
|
||||
t.Parallel()
|
||||
rigPath := t.TempDir()
|
||||
manager := &Manager{}
|
||||
|
||||
@@ -487,6 +503,7 @@ func TestInitBeadsRejectsInvalidPrefix(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeriveBeadsPrefix(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
name string
|
||||
want string
|
||||
@@ -535,6 +552,7 @@ func TestDeriveBeadsPrefix(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSplitCompoundWord(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
word string
|
||||
want []string
|
||||
|
||||
Reference in New Issue
Block a user