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
§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");
// 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_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_file<P: Into<PathBuf>, S: Into<String>>(
self,
path: P,
content: S,
) -> Self
pub fn with_file<P: Into<PathBuf>, S: Into<String>>( self, path: P, content: S, ) -> Self
Pre-populate a file in memory.
Sourcepub fn get_file(&self, path: &Path) -> Option<String>
pub fn get_file(&self, path: &Path) -> Option<String>
Get the contents of a file (for test assertions).
Sourcepub fn was_written(&self, path: &Path) -> bool
pub fn was_written(&self, path: &Path) -> bool
Check if a file was written (for test assertions).
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 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 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 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