Skip to content

Commit

Permalink
chore: clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
chaosteil committed Feb 19, 2024
1 parent e2a300a commit 17ac6cf
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 35 deletions.
5 changes: 1 addition & 4 deletions src/api/sync/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ fn find_id_index(array: &[serde_json::Value], id: u64) -> Option<usize> {
None
}

fn merge_with_deleted_arrays(
original: &mut Vec<serde_json::Value>,
patch: &Vec<serde_json::Value>,
) {
fn merge_with_deleted_arrays(original: &mut Vec<serde_json::Value>, patch: &[serde_json::Value]) {
if original.is_empty() && patch.is_empty() {
return;
}
Expand Down
2 changes: 0 additions & 2 deletions src/api/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@
//! potential future use.
mod data;
mod state;

pub use state::State;
52 changes: 26 additions & 26 deletions src/interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,32 +208,6 @@ impl FuzzSelect for Task {
}
}

#[cfg(test)]
mod test {
use super::*;

type Selectable<'a> = (i32, &'a str);

impl<'a> FuzzSelect for Selectable<'a> {
type ID = i32;

fn id(&self) -> i32 {
self.0
}
fn name(&self) -> &str {
self.1
}
}

#[test]
fn select_best() {
let select: Vec<Selectable> = vec![(0, "zero"), (1, "one"), (2, "two"), (3, "three")];
assert_eq!(fuzz_select(&select, "one").unwrap().0, 1);
assert_eq!(fuzz_select(&select, "w").unwrap().0, 2);
assert!(fuzz_select(&select, "what").is_err());
}
}

pub fn input_content(content: &str) -> Result<String> {
let mut input = dialoguer::Input::new();
input
Expand Down Expand Up @@ -305,3 +279,29 @@ pub fn input_priority() -> Result<Option<Priority>> {
let selection = select("Priority", &items)?;
Ok(selection.map(|s| items[s]))
}

#[cfg(test)]
mod test {
use super::*;

type Selectable<'a> = (i32, &'a str);

impl<'a> FuzzSelect for Selectable<'a> {
type ID = i32;

fn id(&self) -> i32 {
self.0
}
fn name(&self) -> &str {
self.1
}
}

#[test]
fn select_best() {
let select: Vec<Selectable> = vec![(0, "zero"), (1, "one"), (2, "two"), (3, "three")];
assert_eq!(fuzz_select(&select, "one").unwrap().0, 1);
assert_eq!(fuzz_select(&select, "w").unwrap().0, 2);
assert!(fuzz_select(&select, "what").is_err());
}
}
4 changes: 2 additions & 2 deletions src/tasks/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ mod tests {
};

let f = Filter::new(None);
assert!(f.select(&cfg) == "all".to_owned());
assert!(f.select(&cfg) == *"all");
let f = Filter::new(Some("today".to_owned()));
assert!(f.select(&cfg) == "today".to_owned());
assert!(f.select(&cfg) == *"today");
}
}
2 changes: 1 addition & 1 deletion tests/commands/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl Tool {
.success();

let mock = MockServer::start().await;
let mut cfg = Config::load_prefix(&tmp.path())?;
let mut cfg = Config::load_prefix(tmp.path())?;
cfg.url = Some(url::Url::parse(&mock.uri())?);
cfg.override_time = Some(super::fixtures::FETCH_TIME.trim().parse()?);
cfg.save()?;
Expand Down

0 comments on commit 17ac6cf

Please sign in to comment.