feat(daemon): add BD_SOCKET env var for test isolation (#914)
Add BD_SOCKET environment variable support to override daemon socket path, enabling parallel test isolation via t.TempDir() + t.Setenv(). Changes: - getSocketPath() checks BD_SOCKET first, falls back to dbPath-derived path - getSocketPathForPID() checks BD_SOCKET first (for consistency) - Add daemon_socket_test.go with isolation pattern examples This is a minimal tracer bullet to validate the approach before expanding to full test isolation infrastructure. Backward compatible: default behavior unchanged without env var set.
This commit is contained in:
committed by
GitHub
parent
5dfb838d60
commit
e9e0d7f1e5
@@ -58,8 +58,13 @@ func getEnvBool(key string, defaultValue bool) bool {
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
// getSocketPathForPID determines the socket path for a given PID file
|
||||
// getSocketPathForPID determines the socket path for a given PID file.
|
||||
// If BD_SOCKET env var is set, uses that value instead.
|
||||
func getSocketPathForPID(pidFile string) string {
|
||||
// Check environment variable first (enables test isolation)
|
||||
if socketPath := os.Getenv("BD_SOCKET"); socketPath != "" {
|
||||
return socketPath
|
||||
}
|
||||
// Socket is in same directory as PID file
|
||||
return filepath.Join(filepath.Dir(pidFile), "bd.sock")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user