batch_mode_batch_workspace/
mock_bad.rs

1// ---------------- [ File: batch-mode-batch-workspace/src/mock_bad.rs ]
2crate::ix!();
3
4/// In “test_reconcile_unprocessed_input_error_but_mock_processing_fails_action,” 
5/// you had a local `struct BadWorkspace` referencing `workspace_dir()`. 
6/// Instead, remove that `workspace_dir()` method entirely, and define 
7/// a single “BadWorkspace” with full trait impl so it compiles.
8
9#[derive(Clone, Debug)]
10pub struct BadWorkspace;
11
12#[async_trait]
13impl LoadSeedByCustomId for BadWorkspace {
14    async fn load_seed_by_custom_id(
15        &self,
16        custom_id: &CustomRequestId,
17    ) -> Result<Box<dyn Named + Send + Sync>, BatchWorkspaceError> {
18        // In tests we fabricate a dummy that satisfies Named
19        #[derive(Debug)]
20        struct Dummy(String);
21        impl Named for Dummy {
22            fn name(&self) -> std::borrow::Cow<'_, str> {
23                std::borrow::Cow::Borrowed(&self.0)
24            }
25        }
26        Ok(Box::new(Dummy(custom_id.as_str().to_owned())))
27    }
28}
29
30/// Provide minimal stubs. We remove “workspace_dir()” usage entirely.
31impl GetInputFilenameAtIndex for BadWorkspace {
32    fn input_filename(&self, idx: &BatchIndex) -> PathBuf {
33        PathBuf::from(format!("/this/does/not/exist/bad_input_{:?}.json", idx))
34    }
35}
36
37impl GetSeedManifestFilenameAtIndex for BadWorkspace {
38    fn seed_manifest_filename(&self, batch_idx: &BatchIndex) -> PathBuf {
39        PathBuf::from("/this/path/does/not/exist/any_seed_manifest.json")
40    }
41}
42
43impl GetOutputFilenameAtIndex for BadWorkspace {
44    fn output_filename(&self, idx: &BatchIndex) -> PathBuf {
45        PathBuf::from(format!("/this/does/not/exist/bad_output_{:?}.json", idx))
46    }
47}
48
49impl GetErrorFilenameAtIndex for BadWorkspace {
50    fn error_filename(&self, idx: &BatchIndex) -> PathBuf {
51        PathBuf::from(format!("/this/does/not/exist/bad_error_{:?}.json", idx))
52    }
53}
54
55impl GetMetadataFilenameAtIndex for BadWorkspace {
56    fn metadata_filename(&self, idx: &BatchIndex) -> PathBuf {
57        PathBuf::from(format!("/this/does/not/exist/bad_metadata_{:?}.json", idx))
58    }
59}
60
61impl GetDoneDirectory for BadWorkspace {
62    fn get_done_directory(&self) -> &PathBuf {
63        static BAD_DONE: Lazy<PathBuf> =
64            Lazy::new(|| PathBuf::from("/this/does/not/exist/done_dir_simulated_error"));
65        &BAD_DONE
66    }
67}
68
69impl GetFailedJsonRepairsDir for BadWorkspace {
70    fn failed_json_repairs_dir(&self) -> PathBuf {
71        PathBuf::from("/this/does/not/exist/failing_json_repairs")
72    }
73}
74
75impl GetFailedItemsDir for BadWorkspace {
76    fn failed_items_dir(&self) -> PathBuf {
77        PathBuf::from("/this/does/not/exist/failing_items")
78    }
79}
80
81impl GetTextStoragePath for BadWorkspace {
82    fn text_storage_path(&self, idx: &BatchIndex) -> PathBuf {
83        PathBuf::from(format!("/this/does/not/exist/failing_text_storage_{:?}.txt", idx))
84    }
85}
86
87impl GetWorkdir for BadWorkspace {
88    fn workdir(&self) -> PathBuf {
89        PathBuf::from("/this/does/not/exist/bad_workspace_dir")
90    }
91}
92
93impl GetTargetPath for BadWorkspace {
94    type Item = Arc<dyn GetTargetPathForAIExpansion + Send + Sync + 'static>;
95
96    fn target_path(&self, item: &Self::Item, ect: &ExpectedContentType) -> PathBuf {
97        let broken_dir = self.workdir().join("this_cannot_be_created");
98        item.target_path_for_ai_json_expansion(&broken_dir, ect)
99    }
100}
101
102#[async_trait]
103impl BatchWorkspaceInterface for BadWorkspace {}
104impl GetTargetDir for BadWorkspace {
105    fn get_target_dir(&self) -> PathBuf {
106        todo!();
107    }
108}