Skip to content

Commit

Permalink
Merge pull request #39 from meilisearch/update-dependencies
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
irevoire authored Jul 2, 2024
2 parents 7a0c2a6 + f6a9de2 commit e55b610
Show file tree
Hide file tree
Showing 15 changed files with 137 additions and 136 deletions.
16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "deserr"
version = "0.6.0"
version = "0.6.2"
authors = ["Lo <[email protected]>", "Tamo <[email protected]>"]
license = "MIT OR Apache-2.0"
description = "Deserialization library with focus on error handling"
Expand All @@ -13,11 +13,11 @@ edition = "2021"
[dependencies]
serde_json = { version = "1.0", optional = true }
serde-cs = { version = "0.2.4", optional = true }
actix-web = { version = "4.3.0", default-features = false, optional = true }
futures = { version = "0.3.25", optional = true }
deserr-internal = { version = "=0.6.0", path = "derive" }
strsim = "0.10.0"
actix-http = { version = "3.3.0", optional = true }
actix-web = { version = "4.8.0", default-features = false, optional = true }
futures = { version = "0.3.30", optional = true }
deserr-internal = { version = "=0.6.2", path = "derive" }
strsim = "0.11.1"
actix-http = { version = "3.8.0", optional = true }
actix-utils = { version = "3.0.1", optional = true }
serde_urlencoded = "0.7.1"

Expand All @@ -29,11 +29,11 @@ actix-web = ["dep:actix-web", "futures", "actix-http", "actix-utils"]

[dev-dependencies]
automod = "1.0"
insta = { version = "1.23.0", features = ["json"] }
insta = { version = "1.39.0", features = ["json"] }
rustversion = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_derive = "1.0"
trybuild = { version = "1.0.49", features = ["diff"] }
trybuild = { version = "1.0.96", features = ["diff"] }

[workspace]
members = ["derive", "examples/*"]
Expand Down
4 changes: 2 additions & 2 deletions derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "deserr-internal"
version = "0.6.0"
version = "0.6.2"
authors = ["Lo <[email protected]>", "Tamo <[email protected]>"]
license = "MIT OR Apache-2.0"
description = "Derive macros for Deserr. Use the re-exports from the deserr crate instead."
Expand All @@ -12,7 +12,7 @@ proc-macro = true

[dependencies]
proc-macro2 = "1.0"
quote = "1.0.2"
quote = "1.0.36"
syn = { version = "2.0", features=["extra-traits", "parsing"]}
convert_case = "0.6.0"

Expand Down
18 changes: 9 additions & 9 deletions examples/actix_web_server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
actix-http = { version = "3.2.2", default-features = false, features = ["compress-brotli", "compress-gzip", "rustls"] }
actix-web = { version = "4.2.1", default-features = false, features = ["macros", "compress-brotli", "compress-gzip", "cookies", "rustls"] }
anyhow = "1.0.68"
actix-http = { version = "3.8.0", default-features = false, features = ["compress-brotli", "compress-gzip", "rustls"] }
actix-web = { version = "4.8.0", default-features = false, features = ["macros", "compress-brotli", "compress-gzip", "cookies", "rustls"] }
anyhow = "1.0.86"
deserr = { path = "../../", features = ["actix-web"] }
env_logger = "0.10.0"
futures = "0.3.25"
futures-util = "0.3.25"
log = "0.4.17"
serde = { version = "1.0.152", features = ["derive"] }
serde_json = "1.0.91"
env_logger = "0.11.3"
futures = "0.3.30"
futures-util = "0.3.30"
log = "0.4.22"
serde = { version = "1.0.203", features = ["derive"] }
serde_json = "1.0.120"
5 changes: 3 additions & 2 deletions examples/implements_deserr_manually.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ struct Query {
/// - `"jorts"`
/// - `["jorts", "jean"]`
/// - `["jorts", ["bilbo", "bob"], "jean"]`
#[allow(dead_code)]
#[derive(Debug)]
enum Filter {
Array(Vec<Filter>),
Expand Down Expand Up @@ -111,12 +112,12 @@ fn main() {

// And when an error arise, we get the nice error from the json error handler.
let error = deserialize::<Filter, _, JsonError>(json!(["jorts", "is", ["a", 10]])).unwrap_err();
insta::assert_display_snapshot!(error, @"Invalid value type at `[2][1]`: expected a string or an array, but found a positive integer: `10`");
insta::assert_snapshot!(error, @"Invalid value type at `[2][1]`: expected a string or an array, but found a positive integer: `10`");

// But since we're generic over the error type we can as well switch to query parameter error!
let error =
deserialize::<Filter, _, QueryParamError>(json!(["jorts", "is", "a", 10])).unwrap_err();
insta::assert_display_snapshot!(error, @"Invalid value type for parameter `[3]`: expected a string, but found an integer: `10`");
insta::assert_snapshot!(error, @"Invalid value type for parameter `[3]`: expected a string, but found an integer: `10`");

// And as expected, using this `Filter` type from another struct that got its `Deserr` implementation from the derive macro just works.
let filter =
Expand Down
84 changes: 42 additions & 42 deletions src/errors/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,24 +232,24 @@ mod tests {

#[test]
fn test_value_kinds_description_json() {
insta::assert_display_snapshot!(value_kinds_description_json(&[]), @"a different value");

insta::assert_display_snapshot!(value_kinds_description_json(&[ValueKind::Boolean]), @"a boolean");
insta::assert_display_snapshot!(value_kinds_description_json(&[ValueKind::Integer]), @"a positive integer");
insta::assert_display_snapshot!(value_kinds_description_json(&[ValueKind::NegativeInteger]), @"a negative integer");
insta::assert_display_snapshot!(value_kinds_description_json(&[ValueKind::Integer]), @"a positive integer");
insta::assert_display_snapshot!(value_kinds_description_json(&[ValueKind::String]), @"a string");
insta::assert_display_snapshot!(value_kinds_description_json(&[ValueKind::Sequence]), @"an array");
insta::assert_display_snapshot!(value_kinds_description_json(&[ValueKind::Map]), @"an object");

insta::assert_display_snapshot!(value_kinds_description_json(&[ValueKind::Integer, ValueKind::Boolean]), @"a boolean or a positive integer");
insta::assert_display_snapshot!(value_kinds_description_json(&[ValueKind::Null, ValueKind::Integer]), @"null or a positive integer");
insta::assert_display_snapshot!(value_kinds_description_json(&[ValueKind::Sequence, ValueKind::NegativeInteger]), @"a negative integer or an array");
insta::assert_display_snapshot!(value_kinds_description_json(&[ValueKind::Integer, ValueKind::Float]), @"a number");
insta::assert_display_snapshot!(value_kinds_description_json(&[ValueKind::Integer, ValueKind::Float, ValueKind::NegativeInteger]), @"a number");
insta::assert_display_snapshot!(value_kinds_description_json(&[ValueKind::Integer, ValueKind::Float, ValueKind::NegativeInteger, ValueKind::Null]), @"null or a number");
insta::assert_display_snapshot!(value_kinds_description_json(&[ValueKind::Boolean, ValueKind::Integer, ValueKind::Float, ValueKind::NegativeInteger, ValueKind::Null]), @"null, a boolean, or a number");
insta::assert_display_snapshot!(value_kinds_description_json(&[ValueKind::Null, ValueKind::Boolean, ValueKind::Integer, ValueKind::Float, ValueKind::NegativeInteger, ValueKind::Null]), @"null, a boolean, or a number");
insta::assert_snapshot!(value_kinds_description_json(&[]), @"a different value");

insta::assert_snapshot!(value_kinds_description_json(&[ValueKind::Boolean]), @"a boolean");
insta::assert_snapshot!(value_kinds_description_json(&[ValueKind::Integer]), @"a positive integer");
insta::assert_snapshot!(value_kinds_description_json(&[ValueKind::NegativeInteger]), @"a negative integer");
insta::assert_snapshot!(value_kinds_description_json(&[ValueKind::Integer]), @"a positive integer");
insta::assert_snapshot!(value_kinds_description_json(&[ValueKind::String]), @"a string");
insta::assert_snapshot!(value_kinds_description_json(&[ValueKind::Sequence]), @"an array");
insta::assert_snapshot!(value_kinds_description_json(&[ValueKind::Map]), @"an object");

insta::assert_snapshot!(value_kinds_description_json(&[ValueKind::Integer, ValueKind::Boolean]), @"a boolean or a positive integer");
insta::assert_snapshot!(value_kinds_description_json(&[ValueKind::Null, ValueKind::Integer]), @"null or a positive integer");
insta::assert_snapshot!(value_kinds_description_json(&[ValueKind::Sequence, ValueKind::NegativeInteger]), @"a negative integer or an array");
insta::assert_snapshot!(value_kinds_description_json(&[ValueKind::Integer, ValueKind::Float]), @"a number");
insta::assert_snapshot!(value_kinds_description_json(&[ValueKind::Integer, ValueKind::Float, ValueKind::NegativeInteger]), @"a number");
insta::assert_snapshot!(value_kinds_description_json(&[ValueKind::Integer, ValueKind::Float, ValueKind::NegativeInteger, ValueKind::Null]), @"null or a number");
insta::assert_snapshot!(value_kinds_description_json(&[ValueKind::Boolean, ValueKind::Integer, ValueKind::Float, ValueKind::NegativeInteger, ValueKind::Null]), @"null, a boolean, or a number");
insta::assert_snapshot!(value_kinds_description_json(&[ValueKind::Null, ValueKind::Boolean, ValueKind::Integer, ValueKind::Float, ValueKind::NegativeInteger, ValueKind::Null]), @"null, a boolean, or a number");
}

#[test]
Expand All @@ -261,7 +261,7 @@ mod tests {
}
let value = json!({ "toto": 2 });
let err = deserr::deserialize::<Missing, _, JsonError>(value).unwrap_err();
insta::assert_display_snapshot!(err, @"Missing field `me`");
insta::assert_snapshot!(err, @"Missing field `me`");
}

#[test]
Expand All @@ -273,7 +273,7 @@ mod tests {
}
let value = json!({ "me": [2] });
let err = deserr::deserialize::<Incorrect, _, JsonError>(value).unwrap_err();
insta::assert_display_snapshot!(err, @"Invalid value type at `.me`: expected a positive integer, but found an array: `[2]`");
insta::assert_snapshot!(err, @"Invalid value type at `.me`: expected a positive integer, but found an array: `[2]`");

#[allow(dead_code)]
#[derive(deserr::Deserr, Debug)]
Expand All @@ -290,7 +290,7 @@ mod tests {
}
let value = json!({ "me": "la" });
let err = deserr::deserialize::<MultiIncorrect, _, JsonError>(value).unwrap_err();
insta::assert_display_snapshot!(err, @"Unknown value `la` at `.me`: expected one of `One`, `Two`, `Three`");
insta::assert_snapshot!(err, @"Unknown value `la` at `.me`: expected one of `One`, `Two`, `Three`");

#[allow(dead_code)]
#[derive(deserr::Deserr, Debug)]
Expand All @@ -307,7 +307,7 @@ mod tests {
}
let value = json!({ "me": "la" });
let err = deserr::deserialize::<MultiIncorrectWithRename, _, JsonError>(value).unwrap_err();
insta::assert_display_snapshot!(err, @"Unknown value `la` at `.me`: expected one of `theobjectivecamelisnoice`, `bloup`");
insta::assert_snapshot!(err, @"Unknown value `la` at `.me`: expected one of `theobjectivecamelisnoice`, `bloup`");
}

#[test]
Expand All @@ -320,7 +320,7 @@ mod tests {
}
let value = json!({ "me": 2, "u": "uwu" });
let err = deserr::deserialize::<SingleUnknownField, _, JsonError>(value).unwrap_err();
insta::assert_display_snapshot!(err, @"Unknown field `u`: expected one of `me`");
insta::assert_snapshot!(err, @"Unknown field `u`: expected one of `me`");

#[allow(dead_code)]
#[derive(deserr::Deserr, Debug)]
Expand All @@ -331,7 +331,7 @@ mod tests {
}
let value = json!({ "me": 2, "and": "u", "uwu": "OwO" });
let err = deserr::deserialize::<MultiUnknownField, _, JsonError>(value).unwrap_err();
insta::assert_display_snapshot!(err, @"Unknown field `uwu`: expected one of `me`, `and`");
insta::assert_snapshot!(err, @"Unknown field `uwu`: expected one of `me`, `and`");
}

#[test]
Expand All @@ -344,11 +344,11 @@ mod tests {
}
let value = json!({ "me": [2] });
let err = deserr::deserialize::<UnexpectedTuple, _, JsonError>(value).unwrap_err();
insta::assert_display_snapshot!(err, @"Invalid value at `.me`: the sequence should have exactly 2 elements");
insta::assert_snapshot!(err, @"Invalid value at `.me`: the sequence should have exactly 2 elements");

let value = json!({ "me": [2, 3, 4] });
let err = deserr::deserialize::<UnexpectedTuple, _, JsonError>(value).unwrap_err();
insta::assert_display_snapshot!(err, @"Invalid value at `.me`: the sequence should have exactly 2 elements");
insta::assert_snapshot!(err, @"Invalid value at `.me`: the sequence should have exactly 2 elements");
}

#[test]
Expand All @@ -374,72 +374,72 @@ mod tests {

let value = json!({ "filler": "doggo" });
let err = deserr::deserialize::<DidYouMean, _, JsonError>(value).unwrap_err();
insta::assert_display_snapshot!(err, @"Unknown field `filler`: did you mean `filter`? expected one of `q`, `filter`, `sort`, `attributesToHighlight`");
insta::assert_snapshot!(err, @"Unknown field `filler`: did you mean `filter`? expected one of `q`, `filter`, `sort`, `attributesToHighlight`");

let value = json!({ "sart": "doggo" });
let err = deserr::deserialize::<DidYouMean, _, JsonError>(value).unwrap_err();
insta::assert_display_snapshot!(err, @"Unknown field `sart`: did you mean `sort`? expected one of `q`, `filter`, `sort`, `attributesToHighlight`");
insta::assert_snapshot!(err, @"Unknown field `sart`: did you mean `sort`? expected one of `q`, `filter`, `sort`, `attributesToHighlight`");

let value = json!({ "attributes_to_highlight": "doggo" });
let err = deserr::deserialize::<DidYouMean, _, JsonError>(value).unwrap_err();
insta::assert_display_snapshot!(err, @"Unknown field `attributes_to_highlight`: did you mean `attributesToHighlight`? expected one of `q`, `filter`, `sort`, `attributesToHighlight`");
insta::assert_snapshot!(err, @"Unknown field `attributes_to_highlight`: did you mean `attributesToHighlight`? expected one of `q`, `filter`, `sort`, `attributesToHighlight`");

let value = json!({ "attributesToHighloght": "doggo" });
let err = deserr::deserialize::<DidYouMean, _, JsonError>(value).unwrap_err();
insta::assert_display_snapshot!(err, @"Unknown field `attributesToHighloght`: did you mean `attributesToHighlight`? expected one of `q`, `filter`, `sort`, `attributesToHighlight`");
insta::assert_snapshot!(err, @"Unknown field `attributesToHighloght`: did you mean `attributesToHighlight`? expected one of `q`, `filter`, `sort`, `attributesToHighlight`");

// doesn't match anything

let value = json!({ "a": "doggo" });
let err = deserr::deserialize::<DidYouMean, _, JsonError>(value).unwrap_err();
insta::assert_display_snapshot!(err, @"Unknown field `a`: expected one of `q`, `filter`, `sort`, `attributesToHighlight`");
insta::assert_snapshot!(err, @"Unknown field `a`: expected one of `q`, `filter`, `sort`, `attributesToHighlight`");

let value = json!({ "query": "doggo" });
let err = deserr::deserialize::<DidYouMean, _, JsonError>(value).unwrap_err();
insta::assert_display_snapshot!(err, @"Unknown field `query`: expected one of `q`, `filter`, `sort`, `attributesToHighlight`");
insta::assert_snapshot!(err, @"Unknown field `query`: expected one of `q`, `filter`, `sort`, `attributesToHighlight`");

let value = json!({ "filterable": "doggo" });
let err = deserr::deserialize::<DidYouMean, _, JsonError>(value).unwrap_err();
insta::assert_display_snapshot!(err, @"Unknown field `filterable`: expected one of `q`, `filter`, `sort`, `attributesToHighlight`");
insta::assert_snapshot!(err, @"Unknown field `filterable`: expected one of `q`, `filter`, `sort`, `attributesToHighlight`");

let value = json!({ "sortable": "doggo" });
let err = deserr::deserialize::<DidYouMean, _, JsonError>(value).unwrap_err();
insta::assert_display_snapshot!(err, @"Unknown field `sortable`: expected one of `q`, `filter`, `sort`, `attributesToHighlight`");
insta::assert_snapshot!(err, @"Unknown field `sortable`: expected one of `q`, `filter`, `sort`, `attributesToHighlight`");

// did you mean triggered by an unknown value

let value = json!({ "q": "filler" });
let err = deserr::deserialize::<DidYouMean, _, JsonError>(value).unwrap_err();
insta::assert_display_snapshot!(err, @"Unknown value `filler` at `.q`: did you mean `filter`? expected one of `q`, `filter`, `sort`, `attributesToHighLight`");
insta::assert_snapshot!(err, @"Unknown value `filler` at `.q`: did you mean `filter`? expected one of `q`, `filter`, `sort`, `attributesToHighLight`");

let value = json!({ "q": "sart" });
let err = deserr::deserialize::<DidYouMean, _, JsonError>(value).unwrap_err();
insta::assert_display_snapshot!(err, @"Unknown value `sart` at `.q`: did you mean `sort`? expected one of `q`, `filter`, `sort`, `attributesToHighLight`");
insta::assert_snapshot!(err, @"Unknown value `sart` at `.q`: did you mean `sort`? expected one of `q`, `filter`, `sort`, `attributesToHighLight`");

let value = json!({ "q": "attributes_to_highlight" });
let err = deserr::deserialize::<DidYouMean, _, JsonError>(value).unwrap_err();
insta::assert_display_snapshot!(err, @"Unknown value `attributes_to_highlight` at `.q`: expected one of `q`, `filter`, `sort`, `attributesToHighLight`");
insta::assert_snapshot!(err, @"Unknown value `attributes_to_highlight` at `.q`: expected one of `q`, `filter`, `sort`, `attributesToHighLight`");

let value = json!({ "q": "attributesToHighloght" });
let err = deserr::deserialize::<DidYouMean, _, JsonError>(value).unwrap_err();
insta::assert_display_snapshot!(err, @"Unknown value `attributesToHighloght` at `.q`: did you mean `attributesToHighLight`? expected one of `q`, `filter`, `sort`, `attributesToHighLight`");
insta::assert_snapshot!(err, @"Unknown value `attributesToHighloght` at `.q`: did you mean `attributesToHighLight`? expected one of `q`, `filter`, `sort`, `attributesToHighLight`");

// doesn't match anything

let value = json!({ "q": "a" });
let err = deserr::deserialize::<DidYouMean, _, JsonError>(value).unwrap_err();
insta::assert_display_snapshot!(err, @"Unknown value `a` at `.q`: expected one of `q`, `filter`, `sort`, `attributesToHighLight`");
insta::assert_snapshot!(err, @"Unknown value `a` at `.q`: expected one of `q`, `filter`, `sort`, `attributesToHighLight`");

let value = json!({ "q": "query" });
let err = deserr::deserialize::<DidYouMean, _, JsonError>(value).unwrap_err();
insta::assert_display_snapshot!(err, @"Unknown value `query` at `.q`: expected one of `q`, `filter`, `sort`, `attributesToHighLight`");
insta::assert_snapshot!(err, @"Unknown value `query` at `.q`: expected one of `q`, `filter`, `sort`, `attributesToHighLight`");

let value = json!({ "q": "filterable" });
let err = deserr::deserialize::<DidYouMean, _, JsonError>(value).unwrap_err();
insta::assert_display_snapshot!(err, @"Unknown value `filterable` at `.q`: expected one of `q`, `filter`, `sort`, `attributesToHighLight`");
insta::assert_snapshot!(err, @"Unknown value `filterable` at `.q`: expected one of `q`, `filter`, `sort`, `attributesToHighLight`");

let value = json!({ "q": "sortable" });
let err = deserr::deserialize::<DidYouMean, _, JsonError>(value).unwrap_err();
insta::assert_display_snapshot!(err, @"Unknown value `sortable` at `.q`: expected one of `q`, `filter`, `sort`, `attributesToHighLight`");
insta::assert_snapshot!(err, @"Unknown value `sortable` at `.q`: expected one of `q`, `filter`, `sort`, `attributesToHighLight`");
}
}
Loading

0 comments on commit e55b610

Please sign in to comment.