summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSebastian Thiel <sthiel@thoughtworks.com>2019-06-02 14:08:49 +0530
committerSebastian Thiel <sthiel@thoughtworks.com>2019-06-02 14:14:55 +0530
commit68569c69f5fdeedddd45635e8eb6d0c255de53f4 (patch)
tree54e1e45537fcbec7a83639cbb883af780326d830 /tests
parent396ab0b5adbb0a29c6b4db77b30893978752329e (diff)
First failing test - even though just a guess :D
Diffstat (limited to 'tests')
-rw-r--r--tests/interactive.rs42
1 files changed, 36 insertions, 6 deletions
diff --git a/tests/interactive.rs b/tests/interactive.rs
index 52ae8bc..1ea19d4 100644
--- a/tests/interactive.rs
+++ b/tests/interactive.rs
@@ -1,25 +1,55 @@
mod app {
- use dua::interactive::App;
- use dua::{ByteFormat, Color, WalkOptions};
+ use dua::interactive::{App, ItemData, Tree};
+ use dua::{ByteFormat, Color, Sorting, WalkOptions};
use failure::Error;
- use std::path::Path;
+ use pretty_assertions::assert_eq;
+ use std::{ffi::OsString, fmt, path::Path};
use tui::backend::TestBackend;
use tui::Terminal;
+ fn debug(item: impl fmt::Debug) -> String {
+ format!("{:?}", item)
+ }
+
#[test]
fn journey_with_single_path() -> Result<(), Error> {
- let mut terminal = Terminal::new(TestBackend::new(40, 20))?;
- let input = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/sample-01");
+ let (terminal, app) = initialized_app_and_terminal("sample-01")?;
+ let expected_tree = sample_01_tree();
+
+ assert_eq!(
+ debug(app.tree),
+ debug(expected_tree),
+ "filesystem graph is stable and matches the directory structure"
+ );
+ Ok(())
+ }
+ fn initialized_app_and_terminal(
+ fixture_path: &str,
+ ) -> Result<(Terminal<TestBackend>, App), Error> {
+ let mut terminal = Terminal::new(TestBackend::new(40, 20))?;
+ let input = Path::new(env!("CARGO_MANIFEST_DIR"))
+ .join("tests/fixtures")
+ .join(fixture_path);
let app = App::initialize(
&mut terminal,
WalkOptions {
threads: 1,
byte_format: ByteFormat::Metric,
color: Color::None,
+ sorting: Sorting::AlphabeticalByFileName,
},
vec![input],
)?;
- Ok(())
+ Ok((terminal, app))
+ }
+
+ fn sample_01_tree() -> Tree {
+ let mut expected_tree = Tree::new();
+ expected_tree.add_node(ItemData {
+ name: OsString::from("foo"),
+ size: 231,
+ });
+ expected_tree
}
}