Skip to content

Commit

Permalink
test: dont load clipboard during tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Beastwick18 committed Jun 22, 2024
1 parent 2a192f2 commit 7322023
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,11 @@ impl App {
let mut last_load_abort: Option<AbortHandle> = None;
let mut last_time: Option<Instant> = None;

let (clipboard, err) =
&mut ClipboardManager::new(ctx.config.clipboard.clone().unwrap_or_default());
let (clipboard, err) = &mut if TEST {
ClipboardManager::empty(ctx.config.clipboard.clone().unwrap_or_default())
} else {
ClipboardManager::new(ctx.config.clipboard.clone().unwrap_or_default())
};
if let Some(err) = err {
ctx.show_error(err);
}
Expand Down Expand Up @@ -551,6 +554,7 @@ impl App {
) {
if TEST && Event::FocusLost == *evt {
ctx.quit();
return;
}

if let Event::Key(KeyEvent {
Expand Down
10 changes: 10 additions & 0 deletions src/clip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ impl ClipboardManager {
)
}

pub fn empty(conf: ClipboardConfig) -> (ClipboardManager, Option<String>) {
(
Self {
clipboard: None,
config: conf,
},
None,
)
}

pub fn try_copy(&mut self, content: &String) -> Result<(), String> {
if let Some(cmd) = self.config.cmd.clone() {
return CommandBuilder::new(cmd)
Expand Down

0 comments on commit 7322023

Please sign in to comment.