feat: add variables

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2024-05-20 23:05:20 +02:00
parent f71b68cd89
commit bbe630e822
14 changed files with 429 additions and 22 deletions

View File

@@ -1,9 +1,12 @@
use std::{cmp::Ordering, path::Path};
use cuddle_clusters::process::ProcessOpts;
use cuddle_clusters::{process::ProcessOpts, ConcreteComponent, IntoComponent};
use walkdir::DirEntry;
pub(crate) async fn run_test(name: &str) -> anyhow::Result<()> {
pub(crate) async fn run_test_with_components(
name: &str,
components: Vec<impl IntoComponent>,
) -> anyhow::Result<()> {
let _ = tracing_subscriber::fmt::try_init();
println!("running for: {name}");
@@ -17,17 +20,25 @@ pub(crate) async fn run_test(name: &str) -> anyhow::Result<()> {
let expected = test_folder.join("expected");
tokio::fs::create_dir_all(&expected).await?;
cuddle_clusters::process_opts(ProcessOpts {
path: test_folder.clone(),
output: actual.clone(),
})
let components: Vec<_> = components.into_iter().map(|p| p.into_component()).collect();
cuddle_clusters::process_opts(
components.clone(),
ProcessOpts {
path: test_folder.clone(),
output: actual.clone(),
},
)
.await?;
if std::env::var("TEST_OVERRIDE") == Ok("true".to_string()) {
cuddle_clusters::process_opts(ProcessOpts {
path: test_folder,
output: expected.clone(),
})
cuddle_clusters::process_opts(
components,
ProcessOpts {
path: test_folder,
output: expected.clone(),
},
)
.await?;
}
@@ -36,6 +47,10 @@ pub(crate) async fn run_test(name: &str) -> anyhow::Result<()> {
Ok(())
}
pub(crate) async fn run_test(name: &str) -> anyhow::Result<()> {
run_test_with_components(name, Vec::<ConcreteComponent>::new()).await
}
async fn compare(expected: &Path, actual: &Path) -> anyhow::Result<()> {
let mut exp = walk_dir(expected)?;
let mut act = walk_dir(actual)?;