use insta::Settings;
use rstest::fixture;
use std::path::PathBuf;
use crate::output_mode::OutputMode;
use crate::output_prefs::{OutputPrefs, resolve_from_theme_with};
use crate::theme::{ThemeContext, ThemePreference};
pub(crate) type NoColorEnv = fn(Option<String>, &str) -> Option<String>;
#[fixture]
pub(crate) fn no_color_env() -> NoColorEnv {
|no_color, key| match key {
"NO_COLOR" => no_color,
_ => None,
}
}
pub(crate) fn snapshot_settings(subdir: &str) -> Settings {
let mut settings = Settings::new();
settings.set_snapshot_path(
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("src")
.join("snapshots")
.join(subdir),
);
settings
}
pub(crate) fn theme_prefs(theme: ThemePreference) -> OutputPrefs {
resolve_from_theme_with(
Some(theme),
ThemeContext::new(None, None, OutputMode::Standard),
|_| None,
)
}