Skip to content

Commit

Permalink
format: applied cargo clippy --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Oct 19, 2023
1 parent b1f7373 commit 55ddb98
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion aw-datastore/src/datastore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ impl DatastoreInstance {
}
};

match stmt.query_row([key], |row| Ok(row.get(1)?)) {
match stmt.query_row([key], |row| row.get(1)) {
Ok(result) => Ok(result),
Err(err) => match err {
rusqlite::Error::QueryReturnedNoRows => {
Expand Down
6 changes: 3 additions & 3 deletions aw-datastore/tests/datastore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ mod datastore_tests {

// Get all events
let fetched_events_all = ds.get_events(&bucket.id, None, None, None).unwrap();
let expected_fetched_events = vec![&e2, &e1];
let expected_fetched_events = [&e2, &e1];
assert_eq!(fetched_events_all.len(), 2);
for i in 0..fetched_events_all.len() {
let expected = &expected_fetched_events[i];
Expand Down Expand Up @@ -268,7 +268,7 @@ mod datastore_tests {

// Get all events
let fetched_events_all = ds.get_events(&bucket.id, None, None, None).unwrap();
let expected_fetched_events = vec![&e2, &e1];
let expected_fetched_events = [&e2, &e1];
assert_eq!(fetched_events_all.len(), 2);
for i in 0..fetched_events_all.len() {
let expected = &expected_fetched_events[i];
Expand All @@ -286,7 +286,7 @@ mod datastore_tests {

// Get all events
let fetched_events_all = ds.get_events(&bucket.id, None, None, None).unwrap();
let expected_fetched_events = vec![e2];
let expected_fetched_events = [e2];
assert_eq!(fetched_events_all.len(), 1);
for i in 0..fetched_events_all.len() {
let expected = &expected_fetched_events[i];
Expand Down
14 changes: 7 additions & 7 deletions aw-query/tests/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ mod query_tests {

let code = String::from("True;False;a=True;return True;");
match aw_query::query(&code, &interval, &ds).unwrap() {
aw_query::DataType::Bool(b) => assert_eq!(b, true),
aw_query::DataType::Bool(b) => assert!(b),
ref data => panic!("Wrong datatype, {data:?}"),
};
}
Expand All @@ -129,42 +129,42 @@ mod query_tests {
// number comparison true
let code = String::from("return 1==1;");
match aw_query::query(&code, &interval, &ds).unwrap() {
aw_query::DataType::Bool(b) => assert_eq!(b, true),
aw_query::DataType::Bool(b) => assert!(b),
ref data => panic!("Wrong datatype, {data:?}"),
};

// number comparison false
let code = String::from("return 2==1;");
match aw_query::query(&code, &interval, &ds).unwrap() {
aw_query::DataType::Bool(b) => assert_eq!(b, false),
aw_query::DataType::Bool(b) => assert!(!b),
ref data => panic!("Wrong datatype, {data:?}"),
};

// string comparison true
let code = String::from(r#"return "a"=="a";"#);
match aw_query::query(&code, &interval, &ds).unwrap() {
aw_query::DataType::Bool(b) => assert_eq!(b, true),
aw_query::DataType::Bool(b) => assert!(b),
ref data => panic!("Wrong datatype, {data:?}"),
};

// string comparison false
let code = String::from(r#"return "a"=="b";"#);
match aw_query::query(&code, &interval, &ds).unwrap() {
aw_query::DataType::Bool(b) => assert_eq!(b, false),
aw_query::DataType::Bool(b) => assert!(!b),
ref data => panic!("Wrong datatype, {data:?}"),
};

// bool comparison true
let code = String::from("return True==True;");
match aw_query::query(&code, &interval, &ds).unwrap() {
aw_query::DataType::Bool(b) => assert_eq!(b, true),
aw_query::DataType::Bool(b) => assert!(b),
ref data => panic!("Wrong datatype, {data:?}"),
};

// bool comparison false
let code = String::from("return False==True;");
match aw_query::query(&code, &interval, &ds).unwrap() {
aw_query::DataType::Bool(b) => assert_eq!(b, false),
aw_query::DataType::Bool(b) => assert!(!b),
ref data => panic!("Wrong datatype, {data:?}"),
};

Expand Down
6 changes: 3 additions & 3 deletions aw-server/src/endpoints/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ impl<'r> Responder<'r, 'static> for BucketsExportRocket {

use aw_datastore::DatastoreError;

impl Into<HttpErrorJson> for DatastoreError {
fn into(self) -> HttpErrorJson {
match self {
impl From<DatastoreError> for HttpErrorJson {
fn from(val: DatastoreError) -> Self {
match val {
DatastoreError::NoSuchBucket(bucket_id) => HttpErrorJson::new(
Status::NotFound,
format!("The requested bucket '{bucket_id}' does not exist"),
Expand Down
12 changes: 6 additions & 6 deletions aw-transform/src/classify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ fn test_rule() {
let rule_from_regex = Rule::from(Regex::new("test").unwrap());
let rule_from_new = Rule::Regex(RegexRule::new("test", false).unwrap());
let rule_none = Rule::None;
assert_eq!(rule_from_regex.matches(&e_match), true);
assert_eq!(rule_from_new.matches(&e_match), true);
assert_eq!(rule_from_regex.matches(&e_no_match), false);
assert_eq!(rule_from_new.matches(&e_no_match), false);
assert!(rule_from_regex.matches(&e_match));
assert!(rule_from_new.matches(&e_match));
assert!(!rule_from_regex.matches(&e_no_match));
assert!(!rule_from_new.matches(&e_no_match));

assert_eq!(rule_none.matches(&e_match), false);
assert!(!rule_none.matches(&e_match));
}

#[test]
Expand All @@ -154,7 +154,7 @@ fn test_rule_lookahead() {
.insert("test".into(), serde_json::json!("testing lookahead"));

let rule_from_regex = Rule::from(Regex::new("testing (?!lookahead)").unwrap());
assert_eq!(rule_from_regex.matches(&e_match), false);
assert!(!rule_from_regex.matches(&e_match));
}

#[test]
Expand Down

0 comments on commit 55ddb98

Please sign in to comment.