-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Introduce url_query module to help with adding url query parameters * Implement AppendUrlQueryPairs for PostListParams * Add helper macros that implement AsQueryValue for given type * Implement AsQueryValue for post param types * Implement unit tests for QueryPairsExtension
- Loading branch information
Showing
9 changed files
with
318 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,9 @@ | ||
use crate::url_query::AppendUrlQueryPairs; | ||
use url::Url; | ||
|
||
#[cfg(test)] | ||
pub fn assert_expected_query_pairs<'a>( | ||
query_pairs: impl IntoIterator<Item = (&'a str, String)>, | ||
expected_pairs: &[(&'a str, &str)], | ||
) { | ||
let mut query_pairs = query_pairs.into_iter().collect::<Vec<_>>(); | ||
let mut expected_pairs: Vec<(&str, String)> = expected_pairs | ||
.iter() | ||
.map(|(k, v)| (*k, v.to_string())) | ||
.collect(); | ||
// The order of query pairs doesn't matter | ||
query_pairs.sort(); | ||
expected_pairs.sort(); | ||
assert_eq!(query_pairs, expected_pairs); | ||
pub fn assert_expected_query_pairs(params: impl AppendUrlQueryPairs, expected_query: &str) { | ||
let mut url = Url::parse("https://example.com").unwrap(); | ||
params.append_query_pairs(&mut url.query_pairs_mut()); | ||
assert_eq!(url.query(), Some(expected_query)); | ||
} |
Oops, something went wrong.