refactor: clean up namespace errors

The namespace error was poorly refactored and duplicated the prefix
string. The "rejected" case is now also tested.
pull/24376/head
Dom Dwyer 2023-01-26 16:44:10 +01:00
parent 3a9b5a4d29
commit 105e354299
No known key found for this signature in database
GPG Key ID: E4C40DBD9157879A
1 changed files with 9 additions and 3 deletions

View File

@ -85,7 +85,7 @@ pub enum Error {
/// name into a [`NamespaceId`].
///
/// [`NamespaceId`]: data_types::NamespaceId
#[error("failed to resolve namespace ID: {0}")]
#[error(transparent)]
NamespaceResolver(#[from] crate::namespace_resolver::Error),
/// The router is currently servicing the maximum permitted number of
@ -561,7 +561,7 @@ mod tests {
use super::*;
use crate::{
dml_handlers::mock::{MockDmlHandler, MockDmlHandlerCall},
namespace_resolver::mock::MockNamespaceResolver,
namespace_resolver::{mock::MockNamespaceResolver, NamespaceCreationError},
};
use assert_matches::assert_matches;
use data_types::{NamespaceId, NamespaceNameError};
@ -1513,10 +1513,16 @@ mod tests {
crate::namespace_resolver::Error::Lookup(e)
}),
"failed to resolve namespace ID: \
failed to resolve namespace ID: \
name [name] already exists",
),
(
NamespaceResolver(
crate::namespace_resolver::Error::Create(NamespaceCreationError::Reject("bananas".to_string()))
),
"rejecting write due to non-existing namespace: bananas",
),
(
RequestLimit,
"this service is overloaded, please try again later",