Use BTreeMap
instead of HashMap
As ordering of `BTreeMap` is easier for testing and the difference does not really matter.
This commit is contained in:
parent
a12ad80cba
commit
f0f1d3239d
1 changed files with 7 additions and 7 deletions
14
src/main.rs
14
src/main.rs
|
@ -28,7 +28,7 @@ use sha2::Sha256;
|
|||
use thiserror::Error;
|
||||
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
collections::BTreeMap,
|
||||
fs::File,
|
||||
io::BufReader,
|
||||
net::{IpAddr, Ipv4Addr, SocketAddr},
|
||||
|
@ -122,7 +122,7 @@ impl IpFilter {
|
|||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct Config {
|
||||
hooks: HashMap<String, Hook>,
|
||||
hooks: BTreeMap<String, Hook>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
|
@ -239,7 +239,7 @@ impl Hook {
|
|||
|
||||
#[derive(Debug)]
|
||||
struct Hooks {
|
||||
inner: HashMap<String, String>,
|
||||
inner: BTreeMap<String, String>,
|
||||
}
|
||||
|
||||
impl Hooks {
|
||||
|
@ -254,7 +254,7 @@ impl Hooks {
|
|||
|
||||
let config = request.guard::<&State<Config>>().await.unwrap(); // should never fail
|
||||
let mut valid = false;
|
||||
let mut result = HashMap::new();
|
||||
let mut result = BTreeMap::new();
|
||||
let client_ip = &request
|
||||
.client_ip()
|
||||
.unwrap_or(IpAddr::V4(Ipv4Addr::UNSPECIFIED));
|
||||
|
@ -636,7 +636,7 @@ mod tests {
|
|||
|
||||
#[rocket::async_test]
|
||||
async fn secret() {
|
||||
let mut hooks = HashMap::new();
|
||||
let mut hooks = BTreeMap::new();
|
||||
|
||||
hooks.insert(
|
||||
"test_hook".to_string(),
|
||||
|
@ -804,7 +804,7 @@ mod tests {
|
|||
|
||||
#[rocket::async_test]
|
||||
async fn parse_command_request() {
|
||||
let mut hooks = HashMap::new();
|
||||
let mut hooks = BTreeMap::new();
|
||||
|
||||
hooks.insert(
|
||||
"test_hook".to_string(),
|
||||
|
@ -878,7 +878,7 @@ mod tests {
|
|||
|
||||
#[rocket::async_test]
|
||||
async fn parse_invalid_command_request() {
|
||||
let mut hooks = HashMap::new();
|
||||
let mut hooks = BTreeMap::new();
|
||||
|
||||
hooks.insert(
|
||||
"test_hook".to_string(),
|
||||
|
|
Loading…
Reference in a new issue