pub struct MemoryConfigEnvironment { /* private fields */ }Expand description
In-memory implementation of ConfigEnvironment for testing.
Provides complete isolation from the real environment:
- Injected paths instead of environment variables
- In-memory file storage instead of real filesystem
- Injectable environment variables via
with_env_var()(default: no vars set)
§Example
ⓘ
use crate::config::MemoryConfigEnvironment;
let env = MemoryConfigEnvironment::new()
.with_unified_config_path("/test/config/ralph-workflow.toml")
.with_prompt_path("/test/repo/PROMPT.md")
.with_file("/test/repo/existing.txt", "content")
.with_env_var("RALPH_DEVELOPER_ITERS", "10");
// Write a file
env.write_file(Path::new("/test/new.txt"), "new content")?;
// Verify it was written
assert!(env.was_written(Path::new("/test/new.txt")));
assert_eq!(env.get_file(Path::new("/test/new.txt")), Some("new content".to_string()));Implementations§
Source§impl MemoryConfigEnvironment
impl MemoryConfigEnvironment
Sourcepub fn with_unified_config_path<P: Into<PathBuf>>(self, path: P) -> Self
pub fn with_unified_config_path<P: Into<PathBuf>>(self, path: P) -> Self
Set the unified config path.
Sourcepub fn with_local_config_path<P: Into<PathBuf>>(self, path: P) -> Self
pub fn with_local_config_path<P: Into<PathBuf>>(self, path: P) -> Self
Set the local config path.
Sourcepub fn with_prompt_path<P: Into<PathBuf>>(self, path: P) -> Self
pub fn with_prompt_path<P: Into<PathBuf>>(self, path: P) -> Self
Set the PROMPT.md path.
Sourcepub fn with_worktree_root<P: Into<PathBuf>>(self, path: P) -> Self
pub fn with_worktree_root<P: Into<PathBuf>>(self, path: P) -> Self
Set the worktree root path for testing git worktree scenarios.
Sourcepub fn with_env_var(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_env_var( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Inject an environment variable for testing.
Provides per-test env isolation without mutating the real process environment.
Use this instead of std::env::set_var to avoid #[serial] requirements.
§Example
ⓘ
let env = MemoryConfigEnvironment::new()
.with_env_var("RALPH_DEVELOPER_ITERS", "42")
.with_env_var("RALPH_ISOLATION_MODE", "false");Sourcepub fn was_written(&self, path: &Path) -> bool
pub fn was_written(&self, path: &Path) -> bool
Trait Implementations§
Source§impl Clone for MemoryConfigEnvironment
impl Clone for MemoryConfigEnvironment
Source§fn clone(&self) -> MemoryConfigEnvironment
fn clone(&self) -> MemoryConfigEnvironment
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl ConfigEnvironment for MemoryConfigEnvironment
impl ConfigEnvironment for MemoryConfigEnvironment
Source§fn get_env_var(&self, key: &str) -> Option<String>
fn get_env_var(&self, key: &str) -> Option<String>
Returns an injected env var from the in-memory map.
Returns None for any key not explicitly set via with_env_var(),
providing complete isolation from the real process environment.
Source§fn unified_config_path(&self) -> Option<PathBuf>
fn unified_config_path(&self) -> Option<PathBuf>
Get the path to the unified config file. Read more
Source§fn local_config_path(&self) -> Option<PathBuf>
fn local_config_path(&self) -> Option<PathBuf>
Get the path to the local config file. Read more
Source§fn prompt_path(&self) -> PathBuf
fn prompt_path(&self) -> PathBuf
Get the path to the PROMPT.md file. Read more
Source§fn file_exists(&self, path: &Path) -> bool
fn file_exists(&self, path: &Path) -> bool
Check if a file exists at the given path.
Source§impl Debug for MemoryConfigEnvironment
impl Debug for MemoryConfigEnvironment
Source§impl Default for MemoryConfigEnvironment
impl Default for MemoryConfigEnvironment
Source§fn default() -> MemoryConfigEnvironment
fn default() -> MemoryConfigEnvironment
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MemoryConfigEnvironment
impl RefUnwindSafe for MemoryConfigEnvironment
impl Send for MemoryConfigEnvironment
impl Sync for MemoryConfigEnvironment
impl Unpin for MemoryConfigEnvironment
impl UnsafeUnpin for MemoryConfigEnvironment
impl UnwindSafe for MemoryConfigEnvironment
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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