style: format code for better readability in tests and function signatures
This commit is contained in:
@@ -167,10 +167,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn split_quoted_path() {
|
||||
assert_eq!(
|
||||
shell_split(r#""My App" --flag"#),
|
||||
vec!["My App", "--flag"]
|
||||
);
|
||||
assert_eq!(shell_split(r#""My App" --flag"#), vec!["My App", "--flag"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -105,15 +105,14 @@ impl Plugin for ExternalPlugin {
|
||||
}
|
||||
|
||||
let result = match guard.as_mut() {
|
||||
Some(io) => tokio::time::timeout(
|
||||
std::time::Duration::from_secs(5),
|
||||
do_search(io, query),
|
||||
)
|
||||
.await
|
||||
.unwrap_or_else(|_| {
|
||||
tracing::warn!("plugin {} search timed out", self.name);
|
||||
Err("timeout".into())
|
||||
}),
|
||||
Some(io) => {
|
||||
tokio::time::timeout(std::time::Duration::from_secs(5), do_search(io, query))
|
||||
.await
|
||||
.unwrap_or_else(|_| {
|
||||
tracing::warn!("plugin {} search timed out", self.name);
|
||||
Err("timeout".into())
|
||||
})
|
||||
}
|
||||
None => unreachable!(),
|
||||
};
|
||||
|
||||
|
||||
@@ -57,7 +57,10 @@ impl FrecencyStore {
|
||||
.as_secs();
|
||||
let json = {
|
||||
let mut data = self.data.lock().unwrap();
|
||||
let entry = data.entry(id.to_string()).or_insert(Entry { count: 0, last_used: 0 });
|
||||
let entry = data.entry(id.to_string()).or_insert(Entry {
|
||||
count: 0,
|
||||
last_used: 0,
|
||||
});
|
||||
entry.count += 1;
|
||||
entry.last_used = now;
|
||||
serde_json::to_string(&*data).ok()
|
||||
|
||||
@@ -135,7 +135,10 @@ fn save_to_path(path: &Path, entries: &HashMap<String, CachedEntry>) {
|
||||
}
|
||||
}
|
||||
|
||||
fn build_entries(source: &impl DesktopEntrySource, _frecency: &Arc<FrecencyStore>) -> HashMap<String, CachedEntry> {
|
||||
fn build_entries(
|
||||
source: &impl DesktopEntrySource,
|
||||
_frecency: &Arc<FrecencyStore>,
|
||||
) -> HashMap<String, CachedEntry> {
|
||||
source
|
||||
.entries()
|
||||
.into_iter()
|
||||
@@ -209,7 +212,10 @@ impl AppsPlugin {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn new_for_test(source: impl DesktopEntrySource + 'static, frecency: Arc<FrecencyStore>) -> Self {
|
||||
fn new_for_test(
|
||||
source: impl DesktopEntrySource + 'static,
|
||||
frecency: Arc<FrecencyStore>,
|
||||
) -> Self {
|
||||
Self::new_impl(source, frecency, None)
|
||||
}
|
||||
}
|
||||
@@ -498,8 +504,8 @@ mod tests {
|
||||
#[test]
|
||||
fn apps_loads_from_cache_when_source_is_empty() {
|
||||
let frecency = ephemeral_frecency();
|
||||
let cache_file = std::env::temp_dir()
|
||||
.join(format!("k-launcher-test-{}.bin", std::process::id()));
|
||||
let cache_file =
|
||||
std::env::temp_dir().join(format!("k-launcher-test-{}.bin", std::process::id()));
|
||||
|
||||
// Build entries from a real source and save to temp path
|
||||
let source = MockSource::with(vec![("Firefox", "firefox")]);
|
||||
|
||||
Reference in New Issue
Block a user