1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use std::process::Child;
use crate::{
cli_session::CliSession, config::Config, connect_params::ConnectParams, downloader::Downloader,
};
pub struct Engine {}
impl Engine {
pub fn new() -> Self {
Self {}
}
fn from_cli(&self, cfg: &Config) -> eyre::Result<(ConnectParams, Child)> {
let cli = Downloader::new("0.3.10".into())?.get_cli()?;
let cli_session = CliSession::new();
Ok(cli_session.connect(cfg, &cli)?)
}
pub fn start(&self, cfg: &Config) -> eyre::Result<(ConnectParams, Child)> {
self.from_cli(cfg)
}
}
#[cfg(test)]
mod tests {
use crate::{config::Config, connect_params::ConnectParams};
use super::Engine;
#[test]
fn engine_can_start() {
let engine = Engine::new();
let params = engine.start(&Config::new(None, None, None, None)).unwrap();
assert_ne!(
params.0,
ConnectParams {
port: 123,
session_token: "123".into()
}
)
}
}