pub struct TestEnvironment {
pub temp_dir: TempDir,
pub original_home: Option<String>,
/* private fields */
}
Expand description
Test environment that sets up a temporary foundry directory with proper isolation Uses thread-safe environment variable manipulation following CLI testing best practices
Fields§
§temp_dir: TempDir
§original_home: Option<String>
Implementations§
Source§impl TestEnvironment
impl TestEnvironment
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Create a new test environment with isolated foundry directory Sets HOME environment variable in a thread-safe manner
Sourcepub fn foundry_dir(&self) -> PathBuf
pub fn foundry_dir(&self) -> PathBuf
Get the foundry directory path within the test environment
Sourcepub fn create_project_args(&self, project_name: &str) -> CreateProjectArgs
pub fn create_project_args(&self, project_name: &str) -> CreateProjectArgs
Create valid test arguments for create_project
Sourcepub fn create_spec_args(
&self,
project_name: &str,
feature_name: &str,
) -> CreateSpecArgs
pub fn create_spec_args( &self, project_name: &str, feature_name: &str, ) -> CreateSpecArgs
Create valid test arguments for create_spec
Sourcepub fn load_project_args(&self, project_name: &str) -> LoadProjectArgs
pub fn load_project_args(&self, project_name: &str) -> LoadProjectArgs
Create test arguments for load_project
Sourcepub fn update_spec_args_single(
&self,
project_name: &str,
spec_name: &str,
file_type: &str,
operation: &str,
) -> UpdateSpecArgs
pub fn update_spec_args_single( &self, project_name: &str, spec_name: &str, file_type: &str, operation: &str, ) -> UpdateSpecArgs
Create test arguments for update_spec with single file update
Sourcepub fn update_spec_args_multi(
&self,
project_name: &str,
spec_name: &str,
operation: &str,
spec_content: Option<&str>,
tasks_content: Option<&str>,
notes_content: Option<&str>,
) -> UpdateSpecArgs
pub fn update_spec_args_multi( &self, project_name: &str, spec_name: &str, operation: &str, spec_content: Option<&str>, tasks_content: Option<&str>, notes_content: Option<&str>, ) -> UpdateSpecArgs
Create test arguments for update_spec with multiple file updates
Sourcepub fn delete_spec_args(
&self,
project_name: &str,
spec_name: &str,
) -> DeleteSpecArgs
pub fn delete_spec_args( &self, project_name: &str, spec_name: &str, ) -> DeleteSpecArgs
Create test arguments for delete_spec
Sourcepub fn install_args(&self, target: &str) -> InstallArgs
pub fn install_args(&self, target: &str) -> InstallArgs
Create test arguments for install command
Sourcepub fn install_args_json(&self, target: &str) -> InstallArgs
pub fn install_args_json(&self, target: &str) -> InstallArgs
Create test arguments for install command with JSON output
Sourcepub fn install_args_with_binary(
&self,
target: &str,
binary_path: &str,
) -> InstallArgs
pub fn install_args_with_binary( &self, target: &str, binary_path: &str, ) -> InstallArgs
Create test arguments for install command with explicit binary path
Sourcepub fn uninstall_args(&self, target: &str, remove_config: bool) -> UninstallArgs
pub fn uninstall_args(&self, target: &str, remove_config: bool) -> UninstallArgs
Create test arguments for uninstall command
Sourcepub fn uninstall_args_json(
&self,
target: &str,
remove_config: bool,
) -> UninstallArgs
pub fn uninstall_args_json( &self, target: &str, remove_config: bool, ) -> UninstallArgs
Create test arguments for uninstall command with JSON output
Sourcepub fn status_args(&self, target: Option<&str>, detailed: bool) -> StatusArgs
pub fn status_args(&self, target: Option<&str>, detailed: bool) -> StatusArgs
Create test arguments for status command
Sourcepub fn parse_install_response(
&self,
json_response: &str,
) -> Result<InstallResponse>
pub fn parse_install_response( &self, json_response: &str, ) -> Result<InstallResponse>
Parse install response JSON for testing
Sourcepub fn parse_uninstall_response(
&self,
json_response: &str,
) -> Result<UninstallResponse>
pub fn parse_uninstall_response( &self, json_response: &str, ) -> Result<UninstallResponse>
Parse uninstall response JSON for testing
Sourcepub async fn install_and_parse(&self, target: &str) -> Result<InstallResponse>
pub async fn install_and_parse(&self, target: &str) -> Result<InstallResponse>
Execute install command and return parsed response for testing
Sourcepub async fn uninstall_and_parse(
&self,
target: &str,
remove_config: bool,
) -> Result<UninstallResponse>
pub async fn uninstall_and_parse( &self, target: &str, remove_config: bool, ) -> Result<UninstallResponse>
Execute uninstall command and return parsed response for testing
Sourcepub async fn install_with_args(
&self,
args: InstallArgs,
) -> Result<InstallResponse>
pub async fn install_with_args( &self, args: InstallArgs, ) -> Result<InstallResponse>
Execute install command with standard args and return parsed response for testing This is a compatibility helper for tests that use the old pattern
Sourcepub async fn uninstall_with_args(
&self,
args: UninstallArgs,
) -> Result<UninstallResponse>
pub async fn uninstall_with_args( &self, args: UninstallArgs, ) -> Result<UninstallResponse>
Execute uninstall command with standard args and return parsed response for testing This is a compatibility helper for tests that use the old pattern
Sourcepub fn status_args_json(
&self,
target: Option<&str>,
detailed: bool,
) -> StatusArgs
pub fn status_args_json( &self, target: Option<&str>, detailed: bool, ) -> StatusArgs
Create test arguments for status command with JSON output for testing
Sourcepub async fn install_text_output(&self, target: &str) -> Result<String>
pub async fn install_text_output(&self, target: &str) -> Result<String>
Execute install command and return human-readable text output for testing
Sourcepub async fn uninstall_text_output(
&self,
target: &str,
remove_config: bool,
) -> Result<String>
pub async fn uninstall_text_output( &self, target: &str, remove_config: bool, ) -> Result<String>
Execute uninstall command and return human-readable text output for testing
Sourcepub async fn get_status_response(
&self,
target: Option<&str>,
detailed: bool,
) -> Result<StatusResponse>
pub async fn get_status_response( &self, target: Option<&str>, detailed: bool, ) -> Result<StatusResponse>
Execute status command and return parsed structured response for testing
Sourcepub fn cursor_config_path(&self) -> PathBuf
pub fn cursor_config_path(&self) -> PathBuf
Get cursor config path within test environment Returns the path where ~/.cursor/mcp.json would be created in the isolated test environment
Sourcepub fn cursor_config_dir(&self) -> PathBuf
pub fn cursor_config_dir(&self) -> PathBuf
Get cursor config directory within test environment
Sourcepub fn claude_code_config_path(&self) -> PathBuf
pub fn claude_code_config_path(&self) -> PathBuf
Get claude code config path within test environment
Sourcepub fn claude_agents_dir(&self) -> PathBuf
pub fn claude_agents_dir(&self) -> PathBuf
Get Claude Code agents directory path within test environment
Sourcepub fn claude_subagent_path(&self) -> PathBuf
pub fn claude_subagent_path(&self) -> PathBuf
Get Claude Code subagent file path within test environment
Sourcepub fn cursor_rules_dir(&self) -> PathBuf
pub fn cursor_rules_dir(&self) -> PathBuf
Get Cursor rules directory path within test environment
Sourcepub fn cursor_rules_path(&self) -> PathBuf
pub fn cursor_rules_path(&self) -> PathBuf
Get Cursor rules file path within test environment
Sourcepub fn invalid_binary_path(&self) -> String
pub fn invalid_binary_path(&self) -> String
Create an invalid binary path for error testing
Sourcepub fn non_executable_binary_path(&self) -> String
pub fn non_executable_binary_path(&self) -> String
Create a binary path that exists but is not executable (for platforms that check)
Sourcepub fn create_existing_cursor_config(&self, content: &str) -> Result<()>
pub fn create_existing_cursor_config(&self, content: &str) -> Result<()>
Create an existing cursor config with custom content for testing conflict scenarios
Sourcepub fn verify_cursor_rules_template(&self) -> Result<()>
pub fn verify_cursor_rules_template(&self) -> Result<()>
Verify that Cursor rules template was created with expected content
Sourcepub fn verify_claude_subagent_template(&self) -> Result<()>
pub fn verify_claude_subagent_template(&self) -> Result<()>
Verify that Claude subagent template was created with expected content
Sourcepub fn with_env_async<F, Fut, T>(&self, f: F) -> T
pub fn with_env_async<F, Fut, T>(&self, f: F) -> T
Execute async test logic with proper environment isolation Uses a simple approach with a dedicated runtime
Sourcepub fn with_env_and_path_async<F, Fut, T>(&self, f: F) -> T
pub fn with_env_and_path_async<F, Fut, T>(&self, f: F) -> T
Execute async test logic with PATH environment variable isolation This is needed for tests that require mock binaries to be in PATH
Sourcepub fn create_mock_binary(&self, name: &str) -> Result<PathBuf>
pub fn create_mock_binary(&self, name: &str) -> Result<PathBuf>
Create a mock binary file for testing Returns the path to the created binary
Sourcepub fn create_mock_claude_binary(&self) -> Result<PathBuf>
pub fn create_mock_claude_binary(&self) -> Result<PathBuf>
Create a mock claude command that handles the specific commands used by the installation process Returns the path to the created binary
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TestEnvironment
impl RefUnwindSafe for TestEnvironment
impl !Send for TestEnvironment
impl Sync for TestEnvironment
impl Unpin for TestEnvironment
impl UnwindSafe for TestEnvironment
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more