xacli_testing/testing/
app.rs1use std::rc::Rc;
7
8use xacli_core::App;
9
10use super::test::TestCase;
11
12pub struct TestingApp {
13 pub(crate) app: Rc<App>,
15
16 pub(crate) config: TestConfig,
18}
19
20#[derive(Debug, Clone)]
22pub struct TestConfig {
23 pub tty: bool,
25}
26
27impl Default for TestConfig {
28 fn default() -> Self {
29 Self { tty: true }
30 }
31}
32
33impl TestingApp {
34 pub fn new(app: App) -> Self {
36 Self {
37 app: Rc::new(app),
38 config: TestConfig::default(),
39 }
40 }
41
42 pub fn config(mut self, config: TestConfig) -> Self {
44 self.config = config;
45 self
46 }
47
48 pub fn test(&self, name: impl Into<String>) -> TestCase {
50 TestCase::new(name)
51 }
52}
53
54impl Default for TestingApp {
55 fn default() -> Self {
56 let app = App::new("test_app", "0.1.0");
57 Self::new(app)
58 }
59}