summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMatan Kushner <hello@matchai.me>2019-04-19 16:57:14 -0400
committerGitHub <noreply@github.com>2019-04-19 16:57:14 -0400
commit022e0002e40d9286677ae59e751b4b873dce6e95 (patch)
tree3769e569da5bbdeeb1c9c9759806deea5e1608f6 /tests
parent6d7485cf5017d05596db85ce49bc979ee3319057 (diff)
Use "context" to contain run details (#14)
* Create "context" to contain run details * Use context in tests and benchmarks
Diffstat (limited to 'tests')
-rw-r--r--tests/common.rs18
1 files changed, 13 insertions, 5 deletions
diff --git a/tests/common.rs b/tests/common.rs
index 4bc62a5fa..a4924ab74 100644
--- a/tests/common.rs
+++ b/tests/common.rs
@@ -1,18 +1,26 @@
use clap::{App, Arg};
+use starship::context::Context;
use starship::modules;
-use std::path::Path;
+use std::path::PathBuf;
-pub fn render_segment(module: &str, path: &Path) -> String {
- render_segment_with_status(module, path, "0")
+pub fn render_segment<T>(module: &str, path: T) -> String
+where
+ T: Into<PathBuf>,
+{
+ render_segment_with_status(module, &path.into(), "0")
}
-pub fn render_segment_with_status(module: &str, path: &Path, status: &str) -> String {
+pub fn render_segment_with_status<T>(module: &str, path: T, status: &str) -> String
+where
+ T: Into<PathBuf>,
+{
// Create an `Arg` with status_code of "0"
let args = App::new("starship")
.arg(Arg::with_name("status_code"))
.get_matches_from(vec!["starship", status]);
+ let context = Context::new_with_dir(args, path.into());
- let segment = modules::handle(module, path, &args);
+ let segment = modules::handle(module, &context);
segment.unwrap().output()
}