summaryrefslogtreecommitdiffstats
path: root/src/config/testutils.rs
blob: 05bddd677deb0a5add3ea94f325a2b8caf7f3f05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
use std::io::Write;

use tempfile::NamedTempFile;

use crate::git::Config;

pub(crate) fn with_git_config<F>(lines: &[&str], callback: F)
where F: FnOnce(Config) {
	let tmp_file = NamedTempFile::new().unwrap();
	writeln!(tmp_file.as_file(), "{}", lines.join("\n")).unwrap();
	callback(Config::open(tmp_file.path()).unwrap());
}