50 lines
1.7 KiB
Rust
50 lines
1.7 KiB
Rust
//! The entry-point name validation is core's ([`alkstore`]'s
|
|
//! `validate_shared_name` / `validate_local_name` — ADR-008 §4), same
|
|
//! as every engine; this module carries no new rule, only the mem
|
|
//! engine's pin that the rule it routes every future entry point
|
|
//! through is the family rule: empty and whitespace-only names are
|
|
//! `InvalidName`, the reserved prefix `__alkstore_` is `ReservedName`,
|
|
//! and the one reserved string (`__alkstore_listener_reconnected__`
|
|
//! — the Postgres reconnect channel, unused on this engine) is still
|
|
//! rejected because it carries the prefix.
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use alkstore::Error;
|
|
|
|
#[test]
|
|
fn empty_and_whitespace_only_names_are_invalid() {
|
|
for name in ["", " "] {
|
|
assert!(
|
|
matches!(
|
|
alkstore::validate_shared_name(name),
|
|
Err(Error::InvalidName { .. })
|
|
),
|
|
"`{name}` validates as `InvalidName` on the shared kind"
|
|
);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn reserved_prefix_names_are_rejected() {
|
|
assert!(matches!(
|
|
alkstore::validate_shared_name("__alkstore_scheduler"),
|
|
Err(Error::ReservedName { .. })
|
|
));
|
|
}
|
|
|
|
#[test]
|
|
fn the_reserved_listener_string_is_rejected_even_though_unused_here() {
|
|
assert!(
|
|
alkstore::validate_shared_name(alkstore::RESERVED_LISTENER_RECONNECTED).is_err(),
|
|
"the reserved string is unused on this engine but still rejected"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn ordinary_names_validate() {
|
|
assert!(alkstore::validate_shared_name("orders").is_ok());
|
|
assert!(alkstore::validate_local_name("__alkstore_-prefixed-local-ids-are-legal").is_ok());
|
|
}
|
|
}
|