diff options
| author | Conrad Ludgate <conrad.ludgate@truelayer.com> | 2022-04-21 08:05:57 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-21 08:05:57 +0100 |
| commit | 48747e3b7c542c696003f71ef4b4ae457934e57c (patch) | |
| tree | 0bbde7136b84cda46cdb758d2cbeda67ca436ee8 /atuin-client/src/import/fish.rs | |
| parent | Use the count cache (#312) (diff) | |
| download | atuin-48747e3b7c542c696003f71ef4b4ae457934e57c.zip | |
A few minor tweaks (#314)
* use bail macro
replace client database errors
remove dead code
* fix test
Diffstat (limited to 'atuin-client/src/import/fish.rs')
| -rw-r--r-- | atuin-client/src/import/fish.rs | 50 |
1 files changed, 18 insertions, 32 deletions
diff --git a/atuin-client/src/import/fish.rs b/atuin-client/src/import/fish.rs index 4079e122..70639264 100644 --- a/atuin-client/src/import/fish.rs +++ b/atuin-client/src/import/fish.rs @@ -144,26 +144,9 @@ impl<R: Read> Iterator for Fish<R> { #[cfg(test)] mod test { - use chrono::{TimeZone, Utc}; use std::io::Cursor; use super::Fish; - use crate::history::History; - - // simple wrapper for fish history entry - macro_rules! fishtory { - ($timestamp:literal, $command:literal) => { - History::new( - Utc.timestamp($timestamp, 0), - $command.into(), - "unknown".into(), - -1, - -1, - None, - None, - ) - }; - } #[test] fn parse_complex() { @@ -201,21 +184,24 @@ ERROR - ~/.local/share/fish/fish_history "#; let cursor = Cursor::new(input); - let fish = Fish::new(cursor).unwrap(); + let mut fish = Fish::new(cursor).unwrap(); + + // simple wrapper for fish history entry + macro_rules! fishtory { + ($timestamp:expr, $command:expr) => { + let h = fish.next().expect("missing entry in history").unwrap(); + assert_eq!(h.command.as_str(), $command); + assert_eq!(h.timestamp.timestamp(), $timestamp); + }; + } - let history = fish.collect::<Result<Vec<_>, _>>().unwrap(); - assert_eq!( - history, - vec![ - fishtory!(1639162832, "history --help"), - fishtory!(1639162851, "cat ~/.bash_history"), - fishtory!(1639162890, "ls ~/.local/share/fish/fish_history"), - fishtory!(1639162893, "cat ~/.local/share/fish/fish_history"), - fishtory!(1639162933, "echo \"foo\" \\\n'bar' baz"), - fishtory!(1639162939, "cat ~/.local/share/fish/fish_history"), - fishtory!(1639163063, r#"echo "\"" \\ "\\""#), - fishtory!(1639163066, "cat ~/.local/share/fish/fish_history"), - ] - ); + fishtory!(1639162832, "history --help"); + fishtory!(1639162851, "cat ~/.bash_history"); + fishtory!(1639162890, "ls ~/.local/share/fish/fish_history"); + fishtory!(1639162893, "cat ~/.local/share/fish/fish_history"); + fishtory!(1639162933, "echo \"foo\" \\\n'bar' baz"); + fishtory!(1639162939, "cat ~/.local/share/fish/fish_history"); + fishtory!(1639163063, r#"echo "\"" \\ "\\""#); + fishtory!(1639163066, "cat ~/.local/share/fish/fish_history"); } } |
