spawn_db/commands/test/
run.rs1use crate::commands::{Command, Outcome, TelemetryDescribe, TelemetryInfo};
2use crate::config::Config;
3use crate::sqltest::Tester;
4use anyhow::Result;
5use futures::TryStreamExt;
6
7pub struct RunTest {
8 pub name: Option<String>,
9}
10
11impl TelemetryDescribe for RunTest {
12 fn telemetry(&self) -> TelemetryInfo {
13 TelemetryInfo::new("test run")
14 }
15}
16
17impl Command for RunTest {
18 async fn execute(&self, config: &Config) -> Result<Outcome> {
19 let test_names: Vec<String> = match &self.name {
20 Some(name) => vec![name.clone()],
21 None => {
22 let mut tests: Vec<String> = Vec::new();
23 let mut fs_lister = config
24 .operator()
25 .lister(&config.pather().tests_folder())
26 .await?;
27 while let Some(entry) = fs_lister.try_next().await? {
28 let path = entry.path().to_string();
29 if path.ends_with("/") {
30 tests.push(path)
31 }
32 }
33 tests
34 }
35 };
36
37 for test_name in test_names {
38 let tester = Tester::new(config, &test_name);
39 let result = tester.run(None).await?;
40 println!("{}", result);
41 }
42
43 Ok(Outcome::Success)
44 }
45}