TestEnvironment

Struct TestEnvironment 

Source
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

Source

pub fn new() -> Result<Self>

Create a new test environment with isolated foundry directory Sets HOME environment variable in a thread-safe manner

Source

pub fn foundry_dir(&self) -> PathBuf

Get the foundry directory path within the test environment

Source

pub fn create_project_args(&self, project_name: &str) -> CreateProjectArgs

Create valid test arguments for create_project

Source

pub fn create_spec_args( &self, project_name: &str, feature_name: &str, ) -> CreateSpecArgs

Create valid test arguments for create_spec

Source

pub fn load_project_args(&self, project_name: &str) -> LoadProjectArgs

Create test arguments for load_project

Source

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

Source

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

Source

pub fn delete_spec_args( &self, project_name: &str, spec_name: &str, ) -> DeleteSpecArgs

Create test arguments for delete_spec

Source

pub fn install_args(&self, target: &str) -> InstallArgs

Create test arguments for install command

Source

pub fn install_args_json(&self, target: &str) -> InstallArgs

Create test arguments for install command with JSON output

Source

pub fn install_args_with_binary( &self, target: &str, binary_path: &str, ) -> InstallArgs

Create test arguments for install command with explicit binary path

Source

pub fn uninstall_args(&self, target: &str, remove_config: bool) -> UninstallArgs

Create test arguments for uninstall command

Source

pub fn uninstall_args_json( &self, target: &str, remove_config: bool, ) -> UninstallArgs

Create test arguments for uninstall command with JSON output

Source

pub fn status_args(&self, target: Option<&str>, detailed: bool) -> StatusArgs

Create test arguments for status command

Source

pub fn parse_install_response( &self, json_response: &str, ) -> Result<InstallResponse>

Parse install response JSON for testing

Source

pub fn parse_uninstall_response( &self, json_response: &str, ) -> Result<UninstallResponse>

Parse uninstall response JSON for testing

Source

pub async fn install_and_parse(&self, target: &str) -> Result<InstallResponse>

Execute install command and return parsed response for testing

Source

pub async fn uninstall_and_parse( &self, target: &str, remove_config: bool, ) -> Result<UninstallResponse>

Execute uninstall command and return parsed response for testing

Source

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

Source

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

Source

pub fn status_args_json( &self, target: Option<&str>, detailed: bool, ) -> StatusArgs

Create test arguments for status command with JSON output for testing

Source

pub async fn install_text_output(&self, target: &str) -> Result<String>

Execute install command and return human-readable text output for testing

Source

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

Source

pub async fn get_status_response( &self, target: Option<&str>, detailed: bool, ) -> Result<StatusResponse>

Execute status command and return parsed structured response for testing

Source

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

Source

pub fn cursor_config_dir(&self) -> PathBuf

Get cursor config directory within test environment

Source

pub fn claude_code_config_path(&self) -> PathBuf

Get claude code config path within test environment

Source

pub fn claude_agents_dir(&self) -> PathBuf

Get Claude Code agents directory path within test environment

Source

pub fn claude_subagent_path(&self) -> PathBuf

Get Claude Code subagent file path within test environment

Source

pub fn cursor_rules_dir(&self) -> PathBuf

Get Cursor rules directory path within test environment

Source

pub fn cursor_rules_path(&self) -> PathBuf

Get Cursor rules file path within test environment

Source

pub fn invalid_binary_path(&self) -> String

Create an invalid binary path for error testing

Source

pub fn non_executable_binary_path(&self) -> String

Create a binary path that exists but is not executable (for platforms that check)

Source

pub fn create_existing_cursor_config(&self, content: &str) -> Result<()>

Create an existing cursor config with custom content for testing conflict scenarios

Source

pub fn verify_cursor_rules_template(&self) -> Result<()>

Verify that Cursor rules template was created with expected content

Source

pub fn verify_claude_subagent_template(&self) -> Result<()>

Verify that Claude subagent template was created with expected content

Source

pub fn with_env_async<F, Fut, T>(&self, f: F) -> T
where F: FnOnce() -> Fut, Fut: Future<Output = T>,

Execute async test logic with proper environment isolation Uses a simple approach with a dedicated runtime

Source

pub fn with_env_and_path_async<F, Fut, T>(&self, f: F) -> T
where F: FnOnce() -> Fut, Fut: Future<Output = T>,

Execute async test logic with PATH environment variable isolation This is needed for tests that require mock binaries to be in PATH

Source

pub fn create_mock_binary(&self, name: &str) -> Result<PathBuf>

Create a mock binary file for testing Returns the path to the created binary

Source

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

Source

pub fn create_cursor_config(&self, servers: &[(&str, &str)]) -> Result<()>

Create a cursor MCP configuration with the given server entries Each entry is a tuple of (server_name, command_path)

Trait Implementations§

Source§

impl Drop for TestEnvironment

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,