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 thiserror::Error;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::BTreeMap,
|
||||||
fs::File,
|
fs::File,
|
||||||
io::BufReader,
|
io::BufReader,
|
||||||
net::{IpAddr, Ipv4Addr, SocketAddr},
|
net::{IpAddr, Ipv4Addr, SocketAddr},
|
||||||
|
@ -122,7 +122,7 @@ impl IpFilter {
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
struct Config {
|
struct Config {
|
||||||
hooks: HashMap<String, Hook>,
|
hooks: BTreeMap<String, Hook>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
@ -239,7 +239,7 @@ impl Hook {
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct Hooks {
|
struct Hooks {
|
||||||
inner: HashMap<String, String>,
|
inner: BTreeMap<String, String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Hooks {
|
impl Hooks {
|
||||||
|
@ -254,7 +254,7 @@ impl Hooks {
|
||||||
|
|
||||||
let config = request.guard::<&State<Config>>().await.unwrap(); // should never fail
|
let config = request.guard::<&State<Config>>().await.unwrap(); // should never fail
|
||||||
let mut valid = false;
|
let mut valid = false;
|
||||||
let mut result = HashMap::new();
|
let mut result = BTreeMap::new();
|
||||||
let client_ip = &request
|
let client_ip = &request
|
||||||
.client_ip()
|
.client_ip()
|
||||||
.unwrap_or(IpAddr::V4(Ipv4Addr::UNSPECIFIED));
|
.unwrap_or(IpAddr::V4(Ipv4Addr::UNSPECIFIED));
|
||||||
|
@ -636,7 +636,7 @@ mod tests {
|
||||||
|
|
||||||
#[rocket::async_test]
|
#[rocket::async_test]
|
||||||
async fn secret() {
|
async fn secret() {
|
||||||
let mut hooks = HashMap::new();
|
let mut hooks = BTreeMap::new();
|
||||||
|
|
||||||
hooks.insert(
|
hooks.insert(
|
||||||
"test_hook".to_string(),
|
"test_hook".to_string(),
|
||||||
|
@ -804,7 +804,7 @@ mod tests {
|
||||||
|
|
||||||
#[rocket::async_test]
|
#[rocket::async_test]
|
||||||
async fn parse_command_request() {
|
async fn parse_command_request() {
|
||||||
let mut hooks = HashMap::new();
|
let mut hooks = BTreeMap::new();
|
||||||
|
|
||||||
hooks.insert(
|
hooks.insert(
|
||||||
"test_hook".to_string(),
|
"test_hook".to_string(),
|
||||||
|
@ -878,7 +878,7 @@ mod tests {
|
||||||
|
|
||||||
#[rocket::async_test]
|
#[rocket::async_test]
|
||||||
async fn parse_invalid_command_request() {
|
async fn parse_invalid_command_request() {
|
||||||
let mut hooks = HashMap::new();
|
let mut hooks = BTreeMap::new();
|
||||||
|
|
||||||
hooks.insert(
|
hooks.insert(
|
||||||
"test_hook".to_string(),
|
"test_hook".to_string(),
|
||||||
|
|
Loading…
Reference in a new issue