Fix Claude settings tests for correct mayor settings location
Tests were creating mayor settings at townRoot/.claude/ but the check now correctly identifies that location as wrong (should be mayor/.claude/). Updated tests to use mayor/.claude/settings.json which is the correct location that doesn't pollute child workspaces via directory traversal. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -179,8 +179,9 @@ func createStaleSettings(t *testing.T, path string, missingElements ...string) {
|
|||||||
func TestClaudeSettingsCheck_ValidMayorSettings(t *testing.T) {
|
func TestClaudeSettingsCheck_ValidMayorSettings(t *testing.T) {
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
|
|
||||||
// Create valid mayor settings
|
// Create valid mayor settings at correct location (mayor/.claude/settings.json)
|
||||||
mayorSettings := filepath.Join(tmpDir, ".claude", "settings.json")
|
// NOT at town root (.claude/settings.json) which is wrong location
|
||||||
|
mayorSettings := filepath.Join(tmpDir, "mayor", ".claude", "settings.json")
|
||||||
createValidSettings(t, mayorSettings)
|
createValidSettings(t, mayorSettings)
|
||||||
|
|
||||||
check := NewClaudeSettingsCheck()
|
check := NewClaudeSettingsCheck()
|
||||||
@@ -285,8 +286,8 @@ func TestClaudeSettingsCheck_ValidPolecatSettings(t *testing.T) {
|
|||||||
func TestClaudeSettingsCheck_MissingEnabledPlugins(t *testing.T) {
|
func TestClaudeSettingsCheck_MissingEnabledPlugins(t *testing.T) {
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
|
|
||||||
// Create stale mayor settings missing enabledPlugins
|
// Create stale mayor settings missing enabledPlugins (at correct location)
|
||||||
mayorSettings := filepath.Join(tmpDir, ".claude", "settings.json")
|
mayorSettings := filepath.Join(tmpDir, "mayor", ".claude", "settings.json")
|
||||||
createStaleSettings(t, mayorSettings, "enabledPlugins")
|
createStaleSettings(t, mayorSettings, "enabledPlugins")
|
||||||
|
|
||||||
check := NewClaudeSettingsCheck()
|
check := NewClaudeSettingsCheck()
|
||||||
@@ -305,8 +306,8 @@ func TestClaudeSettingsCheck_MissingEnabledPlugins(t *testing.T) {
|
|||||||
func TestClaudeSettingsCheck_MissingHooks(t *testing.T) {
|
func TestClaudeSettingsCheck_MissingHooks(t *testing.T) {
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
|
|
||||||
// Create stale settings missing hooks entirely
|
// Create stale settings missing hooks entirely (at correct location)
|
||||||
mayorSettings := filepath.Join(tmpDir, ".claude", "settings.json")
|
mayorSettings := filepath.Join(tmpDir, "mayor", ".claude", "settings.json")
|
||||||
createStaleSettings(t, mayorSettings, "hooks")
|
createStaleSettings(t, mayorSettings, "hooks")
|
||||||
|
|
||||||
check := NewClaudeSettingsCheck()
|
check := NewClaudeSettingsCheck()
|
||||||
@@ -322,8 +323,8 @@ func TestClaudeSettingsCheck_MissingHooks(t *testing.T) {
|
|||||||
func TestClaudeSettingsCheck_MissingPATH(t *testing.T) {
|
func TestClaudeSettingsCheck_MissingPATH(t *testing.T) {
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
|
|
||||||
// Create stale settings missing PATH export
|
// Create stale settings missing PATH export (at correct location)
|
||||||
mayorSettings := filepath.Join(tmpDir, ".claude", "settings.json")
|
mayorSettings := filepath.Join(tmpDir, "mayor", ".claude", "settings.json")
|
||||||
createStaleSettings(t, mayorSettings, "PATH")
|
createStaleSettings(t, mayorSettings, "PATH")
|
||||||
|
|
||||||
check := NewClaudeSettingsCheck()
|
check := NewClaudeSettingsCheck()
|
||||||
@@ -349,8 +350,8 @@ func TestClaudeSettingsCheck_MissingPATH(t *testing.T) {
|
|||||||
func TestClaudeSettingsCheck_MissingDeaconNudge(t *testing.T) {
|
func TestClaudeSettingsCheck_MissingDeaconNudge(t *testing.T) {
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
|
|
||||||
// Create stale settings missing deacon nudge
|
// Create stale settings missing deacon nudge (at correct location)
|
||||||
mayorSettings := filepath.Join(tmpDir, ".claude", "settings.json")
|
mayorSettings := filepath.Join(tmpDir, "mayor", ".claude", "settings.json")
|
||||||
createStaleSettings(t, mayorSettings, "deacon-nudge")
|
createStaleSettings(t, mayorSettings, "deacon-nudge")
|
||||||
|
|
||||||
check := NewClaudeSettingsCheck()
|
check := NewClaudeSettingsCheck()
|
||||||
@@ -376,8 +377,8 @@ func TestClaudeSettingsCheck_MissingDeaconNudge(t *testing.T) {
|
|||||||
func TestClaudeSettingsCheck_MissingStopHook(t *testing.T) {
|
func TestClaudeSettingsCheck_MissingStopHook(t *testing.T) {
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
|
|
||||||
// Create stale settings missing Stop hook
|
// Create stale settings missing Stop hook (at correct location)
|
||||||
mayorSettings := filepath.Join(tmpDir, ".claude", "settings.json")
|
mayorSettings := filepath.Join(tmpDir, "mayor", ".claude", "settings.json")
|
||||||
createStaleSettings(t, mayorSettings, "Stop")
|
createStaleSettings(t, mayorSettings, "Stop")
|
||||||
|
|
||||||
check := NewClaudeSettingsCheck()
|
check := NewClaudeSettingsCheck()
|
||||||
@@ -462,8 +463,8 @@ func TestClaudeSettingsCheck_MultipleStaleFiles(t *testing.T) {
|
|||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
rigName := "testrig"
|
rigName := "testrig"
|
||||||
|
|
||||||
// Create multiple stale settings files
|
// Create multiple stale settings files (all at correct locations)
|
||||||
mayorSettings := filepath.Join(tmpDir, ".claude", "settings.json")
|
mayorSettings := filepath.Join(tmpDir, "mayor", ".claude", "settings.json")
|
||||||
createStaleSettings(t, mayorSettings, "PATH")
|
createStaleSettings(t, mayorSettings, "PATH")
|
||||||
|
|
||||||
deaconSettings := filepath.Join(tmpDir, "deacon", ".claude", "settings.json")
|
deaconSettings := filepath.Join(tmpDir, "deacon", ".claude", "settings.json")
|
||||||
@@ -489,8 +490,8 @@ func TestClaudeSettingsCheck_MultipleStaleFiles(t *testing.T) {
|
|||||||
func TestClaudeSettingsCheck_InvalidJSON(t *testing.T) {
|
func TestClaudeSettingsCheck_InvalidJSON(t *testing.T) {
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
|
|
||||||
// Create invalid JSON file
|
// Create invalid JSON file (at correct location)
|
||||||
mayorSettings := filepath.Join(tmpDir, ".claude", "settings.json")
|
mayorSettings := filepath.Join(tmpDir, "mayor", ".claude", "settings.json")
|
||||||
if err := os.MkdirAll(filepath.Dir(mayorSettings), 0755); err != nil {
|
if err := os.MkdirAll(filepath.Dir(mayorSettings), 0755); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -587,8 +588,8 @@ func TestClaudeSettingsCheck_MixedValidAndStale(t *testing.T) {
|
|||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
rigName := "testrig"
|
rigName := "testrig"
|
||||||
|
|
||||||
// Create valid mayor settings
|
// Create valid mayor settings (at correct location)
|
||||||
mayorSettings := filepath.Join(tmpDir, ".claude", "settings.json")
|
mayorSettings := filepath.Join(tmpDir, "mayor", ".claude", "settings.json")
|
||||||
createValidSettings(t, mayorSettings)
|
createValidSettings(t, mayorSettings)
|
||||||
|
|
||||||
// Create stale witness settings in correct location (missing PATH)
|
// Create stale witness settings in correct location (missing PATH)
|
||||||
|
|||||||
Reference in New Issue
Block a user