Skip to content

Commit

Permalink
Increase coverage of server model and api request building
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasPius committed Apr 4, 2024
1 parent 4975b67 commit 4893292
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,28 @@ impl<Response> AuthenticatedRequest<Response> {
self.request.body.as_deref()
}
}

#[cfg(test)]
mod tests {
use serde::Serialize;

use super::UnauthenticatedRequest;

#[test]
fn extend_query_parameters() {
#[derive(Serialize)]
struct QueryParams {
example: &'static str,
}

assert_eq!(
UnauthenticatedRequest::<()>::new("https://google.com?test=lol".parse().unwrap())
.with_query_params(QueryParams {
example: "Some example here",
})
.unwrap()
.uri,
"https://google.com?test=lol&example=Some+example+here"
);
}
}
13 changes: 13 additions & 0 deletions src/api/server/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,16 @@ pub enum Cancellation {
/// Server has not been cancelled.
Cancellable(Cancellable),
}

#[cfg(test)]
mod tests {
use crate::api::server::ServerId;

#[test]
fn server_id_conversion() {
assert_eq!(ServerId(10), ServerId::from(10));

assert_eq!(u32::from(ServerId(10)), 10);
assert_eq!(ServerId(10), 10);
}
}

0 comments on commit 4893292

Please sign in to comment.