diff --git a/src/bin_foreign_document_test.rs b/src/bin_foreign_document_test.rs index ef20611f..fda831e3 100644 --- a/src/bin_foreign_document_test.rs +++ b/src/bin_foreign_document_test.rs @@ -37,31 +37,19 @@ fn main() -> Result<(), Box> { #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] async fn main_body() -> Result<(), Box> { - let args = std::env::args().skip(1); - if args.is_empty() { - let org_contents = read_stdin_to_string()?; - run_anonymous_compare(org_contents) - } else { - for arg in args { - run_compare_on_file(arg)? - } - Ok(()) - } -} - -fn read_stdin_to_string() -> Result> { - let mut stdin_contents = String::new(); - std::io::stdin() - .lock() - .read_to_string(&mut stdin_contents)?; - Ok(stdin_contents) + let test_config = TestConfig::TestLayer(TestLayer { + name: "foo", + children: vec![TestConfig::SingleFile(SingleFile { + file_path: Path::new("/tmp/test.org"), + })], + }); + Ok(()) } #[derive(Debug)] enum TestConfig<'s> { TestLayer(TestLayer<'s>), SingleFile(SingleFile<'s>), - AnonymousFile(AnonymousFile), } #[derive(Debug)] @@ -72,19 +60,13 @@ struct TestLayer<'s> { #[derive(Debug)] struct SingleFile<'s> { - file_path: &'s str, -} - -#[derive(Debug)] -struct AnonymousFile { - name: String, + file_path: &'s Path, } #[derive(Debug)] enum TestResult<'s> { ResultLayer(ResultLayer<'s>), SingleFileResult(SingleFileResult<'s>), - AnonymousFileResult(AnonymousFileResult), } #[derive(Debug)] @@ -95,18 +77,41 @@ struct ResultLayer<'s> { #[derive(Debug)] struct SingleFileResult<'s> { - name: &'s str, + file_path: &'s Path, + status: TestStatus, } #[derive(Debug)] -struct AnonymousFileResult { - name: String, +pub(crate) enum TestStatus { + Good, + Bad, +} + +impl<'s> TestConfig<'s> { + async fn run_test(&self) -> TestResult<'s> { + match self { + TestConfig::TestLayer(test) => TestResult::ResultLayer(test.run_test().await), + TestConfig::SingleFile(test) => TestResult::SingleFileResult(test.run_test().await), + } + } } impl<'s> SingleFile<'s> { - fn run_test(&self) -> SingleFileResult<'s> { + async fn run_test(&self) -> SingleFileResult<'s> { let result = run_compare_on_file(self.file_path); - // foo + SingleFileResult { + file_path: self.file_path, + status: if result.is_ok() { + TestStatus::Good + } else { + TestStatus::Bad + }, + } + } +} + +impl<'s> TestLayer<'s> { + async fn run_test(&self) -> ResultLayer<'s> { todo!() } }