Skip to content

Commit

Permalink
init/test: Adopt logic from run_tests
Browse files Browse the repository at this point in the history
We were missing the system filtering
  • Loading branch information
srid committed Oct 9, 2024
1 parent 18f97ef commit aa2fc77
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions crates/omnix-cli/tests/command/init.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
use nix_rs::config::NixConfig;
use omnix_init::registry::BUILTIN_REGISTRY;

/// `om init` runs and successfully initializes a template
#[tokio::test]
async fn om_init() -> anyhow::Result<()> {
let registry = BUILTIN_REGISTRY.clone();
let cfg = NixConfig::get().await.as_ref()?;
let current_system = &cfg.system.value;
for url in registry.0.values() {
// TODO: Refactor(DRY) with src/core.rs:run_tests
println!("🕍 Testing template: {}", url);
let templates = omnix_init::config::load_templates(url).await?;
for template in templates {
let tests = &template.template.tests;
for (name, test) in tests {
println!(
"🧪 [{}#{}] Running test: {}",
url, template.template_name, name
);
test.run_test(
&url.with_attr(&format!("{}.{}", template.template_name, name)),
&template,
)
.await?;
if test.can_run_on(current_system) {
println!(
"🧪 [{}#{}] Running test: {}",
url, template.template_name, name
);
test.run_test(
&url.with_attr(&format!("{}.{}", template.template_name, name)),
&template,
)
.await?;
} else {
println!(
"⚠️ Skipping test: {} (cannot run on {})",
name, current_system
);
}
}
}
}
Expand Down

0 comments on commit aa2fc77

Please sign in to comment.