mirror of
https://github.com/alexpasmantier/television.git
synced 2025-06-06 03:25:23 +00:00
wip: fixing a couple of broken tests
This commit is contained in:
parent
5c9bbe8952
commit
ae958f82c5
@ -2,7 +2,7 @@
|
||||
[[cable_channel]]
|
||||
name = "files"
|
||||
source_command = "fd -t f"
|
||||
preview_command = "bat -n --color=always {0}"
|
||||
preview_command = "bat -n --color=always {}"
|
||||
|
||||
# Text
|
||||
[[cable_channel]]
|
||||
@ -72,7 +72,7 @@ preview_command = "aws s3 ls s3://{0}"
|
||||
[[cable_channel]]
|
||||
name = "my-dotfiles"
|
||||
source_command = "fd -t f . $HOME/.config"
|
||||
preview_command = "bat -n --color=always {0}"
|
||||
preview_command = "bat -n --color=always {}"
|
||||
|
||||
# Shell history
|
||||
[[cable_channel]]
|
||||
|
@ -2,13 +2,13 @@
|
||||
[[cable_channel]]
|
||||
name = "files"
|
||||
source_command = "Get-ChildItem -Recurse -File | Select-Object -ExpandProperty FullName"
|
||||
preview_command = "bat -n --color=always {0}"
|
||||
preview_command = "bat -n --color=always {}"
|
||||
|
||||
# Directories
|
||||
[[cable_channel]]
|
||||
name = "dirs"
|
||||
source_command = "Get-ChildItem -Recurse -Directory | Select-Object -ExpandProperty FullName"
|
||||
preview_command = "ls -l {0}"
|
||||
preview_command = "ls -l {}"
|
||||
|
||||
# Environment variables
|
||||
[[cable_channel]]
|
||||
@ -29,7 +29,7 @@ preview_command = "cd '{}' ; git log -n 200 --pretty=medium --all --graph --colo
|
||||
[[cable_channel]]
|
||||
name = "git-diff"
|
||||
source_command = "git diff --name-only"
|
||||
preview_command = "git diff --color=always {0}"
|
||||
preview_command = "git diff --color=always {}"
|
||||
|
||||
[[cable_channel]]
|
||||
name = "git-reflog"
|
||||
@ -56,7 +56,7 @@ preview_command = "docker image inspect {0} | jq -C"
|
||||
[[cable_channel]]
|
||||
name = "my-dotfiles"
|
||||
source_command = "Get-ChildItem -Recurse -File -Path \"$env:USERPROFILE\\AppData\\Roaming\\\""
|
||||
preview_command = "bat -n --color=always {0}"
|
||||
preview_command = "bat -n --color=always {}"
|
||||
|
||||
# Shell history
|
||||
[[cable_channel]]
|
||||
|
@ -438,33 +438,3 @@ impl App {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_maybe_select_1() {
|
||||
let mut app = App::new(
|
||||
CableChannelPrototype::new(
|
||||
"random", "cat", false, None, None, None,
|
||||
),
|
||||
Config::default(),
|
||||
None,
|
||||
AppOptions::default(),
|
||||
&CableChannelPrototypes::default(),
|
||||
);
|
||||
app.television
|
||||
.results_picker
|
||||
.entries
|
||||
.push(Entry::new("test".to_string()));
|
||||
let outcome = app.maybe_select_1();
|
||||
assert!(outcome.is_some());
|
||||
assert_eq!(
|
||||
outcome.unwrap(),
|
||||
ActionOutcome::Entries(FxHashSet::from_iter([Entry::new(
|
||||
"test".to_string(),
|
||||
)]))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ use crate::{
|
||||
/// [[cable_channel]]
|
||||
/// name = "files"
|
||||
/// source_command = "fd -t f"
|
||||
/// preview_command = ":files:"
|
||||
/// preview_command = "cat {}"
|
||||
/// ```
|
||||
#[derive(Clone, Debug, serde::Deserialize, PartialEq)]
|
||||
pub struct CableChannelPrototype {
|
||||
@ -100,20 +100,14 @@ impl CableChannelPrototype {
|
||||
}
|
||||
|
||||
const DEFAULT_PROTOTYPE_NAME: &str = "files";
|
||||
const DEFAULT_SOURCE_COMMAND: &str = "fd -t f";
|
||||
const DEFAULT_PREVIEW_COMMAND: &str = ":files:";
|
||||
pub const DEFAULT_DELIMITER: &str = " ";
|
||||
|
||||
impl Default for CableChannelPrototype {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
name: DEFAULT_PROTOTYPE_NAME.to_string(),
|
||||
source_command: DEFAULT_SOURCE_COMMAND.to_string(),
|
||||
interactive: false,
|
||||
preview_command: Some(DEFAULT_PREVIEW_COMMAND.to_string()),
|
||||
preview_delimiter: Some(DEFAULT_DELIMITER.to_string()),
|
||||
preview_offset: None,
|
||||
}
|
||||
CableChannelPrototypes::default()
|
||||
.get(DEFAULT_PROTOTYPE_NAME)
|
||||
.cloned()
|
||||
.unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -317,10 +317,12 @@ mod tests {
|
||||
|
||||
let post_processed_cli: PostProcessedCli = cli.into();
|
||||
|
||||
assert_eq!(
|
||||
post_processed_cli.channel,
|
||||
CableChannelPrototype::default(),
|
||||
);
|
||||
let expected = CableChannelPrototype {
|
||||
preview_delimiter: Some(":".to_string()),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
assert_eq!(post_processed_cli.channel, expected,);
|
||||
assert_eq!(
|
||||
post_processed_cli.preview_command,
|
||||
Some(PreviewCommand {
|
||||
|
@ -342,9 +342,6 @@ mod tests {
|
||||
ui_scale = 40
|
||||
theme = "television"
|
||||
|
||||
[previewers.file]
|
||||
theme = "Visual Studio Dark"
|
||||
|
||||
[keybindings]
|
||||
toggle_help = ["ctrl-a", "ctrl-b"]
|
||||
confirm_selection = "ctrl-enter"
|
||||
|
@ -219,7 +219,7 @@ mod tests {
|
||||
&config,
|
||||
true,
|
||||
&CableChannelPrototype::new(
|
||||
"STDIN", "cat", false, None, None, None,
|
||||
"stdin", "cat", false, None, None, None,
|
||||
),
|
||||
None,
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user