Skip to content

Commit

Permalink
test: add simple tests to improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadow53 committed Dec 6, 2021
1 parent 33c1a1a commit c3986df
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ci-tests/tests/testers/correct_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,19 @@ def _run_pile_named_config_test(self):
result = self.run_hoard("validate", allow_failure=True, capture_output=True)
assert b'expected "config" to be a pile config: at ["hoards", "invalid_named_pile", "config"]' in result.stdout

def _run_warn_on_invalid_uuid(self):
self.reset()
invalid_id = "invalid"
self.uuid = invalid_id
result = self.run_hoard("backup", capture_output=True)
assert self.uuid != invalid_id
assert b'failed to parse uuid in file' in result.stdout

def run_test(self):
self._run_missing_parent_test()
self._run_pile_named_config_test()
self._run_env_string_named_config_test()
self._run_hoard_named_config_test()
self._run_hoard_named_config_test()
self._run_warn_on_invalid_uuid()


30 changes: 30 additions & 0 deletions src/checkers/history/last_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,36 @@ mod tests {
assert_eq!(last_paths.0.len(), 0);
}

#[test]
fn test_from_pathbuf() {
let path = PathBuf::from("/test/path");
let pile_paths = PilePaths::from(path.clone());
assert_eq!(pile_paths, PilePaths::Anonymous(Some(path)));
}

#[test]
fn test_from_some_pathbuf() {
let path = PathBuf::from("/test/path");
let pile_paths = PilePaths::from(Some(path.clone()));
assert_eq!(pile_paths, PilePaths::Anonymous(Some(path)));
}

#[test]
fn test_from_none_pathbuf() {
let pile_paths = PilePaths::from(None);
assert_eq!(pile_paths, PilePaths::Anonymous(None));
}

#[test]
fn test_from_hashmap() {
let map = hashmap! {
"first".into() => PathBuf::from("/first"),
"second".into() => PathBuf::from("/second"),
};
let pile_paths = PilePaths::from(map.clone());
assert_eq!(pile_paths, PilePaths::Named(map));
}

#[test]
fn test_lastpaths_get_set_hoard() {
let hoard_paths = anonymous_hoard_paths();
Expand Down

0 comments on commit c3986df

Please sign in to comment.