Add meili-snap crate to make writing snapshot tests easier

This commit is contained in:
Loïc Lecrenier 2022-10-11 13:24:53 +02:00 committed by Clément Renault
parent 0af00f6b32
commit 3e4337c91f
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4
16 changed files with 315 additions and 3 deletions

View file

@ -1,13 +1,11 @@
use std::convert::TryFrom;
use std::env;
use std::fs;
use std::io::{BufReader, Read};
use std::num::ParseIntError;
use std::ops::Deref;
use std::path::PathBuf;
use std::str::FromStr;
use std::sync::Arc;
use std::{fmt, fs};
use std::{env, fmt, fs};
use byte_unit::{Byte, ByteError};
use clap::Parser;
@ -646,6 +644,17 @@ fn load_ocsp(filename: &Option<PathBuf>) -> anyhow::Result<Vec<u8>> {
Ok(ret)
}
/// Checks if the key is defined in the environment variables.
/// If not, inserts it with the given value.
pub fn export_to_env_if_not_present<T>(key: &str, value: T)
where
T: AsRef<OsStr>,
{
if let Err(VarError::NotPresent) = std::env::var(key) {
std::env::set_var(key, value);
}
}
/// Functions used to get default value for `Opt` fields, needs to be function because of serde's default attribute.
fn default_db_path() -> PathBuf {