Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitProle::contents and assert_contents (again) #41

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
}
Loading