Skip to content

Commit

Permalink
Add GitProle::contents and assert_contents (again) (#41)
Browse files Browse the repository at this point in the history
Yeah turns out I did need these

Removed in #32
  • Loading branch information
9999years authored Oct 18, 2024
1 parent 14616f4 commit ce9310a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test-harness/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::process::Command;
use camino::Utf8PathBuf;
use clonable_command::Command as ClonableCommand;
use command_error::CommandExt;
use expect_test::Expect;
use git_prole::fs;
use git_prole::Git;
use git_prole::Utf8TempDir;
Expand Down Expand Up @@ -171,7 +172,20 @@ impl GitProle {
/// Construct a repository state which a real repository can be checked against.
///
/// The repository state will rooted in the given directory.
#[track_caller]
pub fn repo_state(&self, root: &str) -> RepoState {
RepoState::new(self.git(root))
}

pub fn contents(&self, path: &str) -> miette::Result<String> {
fs::read_to_string(self.path(path))
}

#[track_caller]
pub fn assert_contents(&self, contents: &[(&str, Expect)]) {
for (path, expect) in contents {
let actual = self.contents(path).unwrap();
expect.assert_eq(&actual);
}
}
}

0 comments on commit ce9310a

Please sign in to comment.