test(admin): add unit test suite for buzz-admin CLI - #2608
Open
SeanGearin wants to merge 1 commit into
Open
Conversation
Signed-off-by: Sean Gearin <sgearin@gmail.com>
SeanGearin
force-pushed
the
test-buzz-admin-coverage
branch
from
July 23, 2026 20:20
58a4c01 to
8ce7e94
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
crates/buzz-admin(the operator CLI: membership management, migrations,channel reconciliation) had zero tests. Its pure logic — role validation,
pubkey parsing/normalization, the NIP-43 same-second-domination timestamp
bump, and the clap argument surface — was only exercised manually against a
live deployment.
Fix
Adds a
#[cfg(test)]unit test module (no Postgres, no Redis, no network)covering:
Cli::command().debug_assert()(same pattern asbuzz-cli's
cli_definition_is_valid), plus parse tests for everysubcommand's argument surface:
add-memberrole default + required--pubkey,remove-memberoptional role filter,product-feedback listlimit default (100) and 1..=1000 range enforcement,
reconcile-channelsoptional
--relay-key, unknown-subcommand rejection.validate_role— acceptsmember/admin; rejectsownerwith theRELAY_OWNER_PUBKEYhint; rejects unknown/case-mismatched roles with theoffending role named in the error.
parse_pubkey_hex— hex round-trip, npub decoding, uppercase-hexnormalization to lowercase, garbage and truncated-hex rejection (error
echoes the input). Fixtures are derived from a fixed secret key at test
time, so no hard-coded pubkey constants can drift.
bumped_created_at— the kind:13534 same-second domination guarddocumented in the module header. The
max(now, newest_existing + 1s)expression is extracted from
publish_membership_list_with_bumpinto anamed pure function (byte-identical behavior, same call site) so the four
cases are testable: no existing list, older existing, same-second
collision, and backwards clock skew.
The only production-code change is that six-line extraction; no behavior
changes.
The suite is wired into
just test-unit(both the cargo-nextest branch andthe
scripts/run-tests.shfallback), so it gates CI's unit job and thelefthook pre-push hook rather than running only on a manual
cargo test -p buzz-admin. Happy to drop those two lines and leave thewiring to a follow-up if you'd rather keep this PR test-only.
Test evidence
(cargo-nextest is not installed in this environment, so
just test-unitexercised the
run-tests.shfallback branch end-to-end; the nextest linemirrors the existing per-package invocations.)