Skip to content

Add unit tests for every Discord command - #22

Merged
KallynGowdy merged 2 commits into
mainfrom
claude/ci-workflow-kl0dgs
Jul 6, 2026
Merged

KallynGowdy merged 2 commits into
mainfrom
claude/ci-workflow-kl0dgs

Conversation

@KallynGowdy

Copy link
Copy Markdown
Contributor

Extracts each command's reply-building and validation logic out of slash_commands.rs (which mixed business logic with ctx.send() calls) into a new poise_impl/replies.rs module of pure functions and Store-dependency-injected functions, then unit tests all of it: 85 tests covering all 11 commands, helpers.rs, BibleBooks, curated verse selection, and chapter/verse text formatting. Adds a FakeStore in-memory test double (store/fake.rs) so Store-backed behavior (prefs, votd, daily verse role) is testable without a database, and a test_support module for inspecting CreateReply embed content.

calc_translation/calc_lang in util/prefs.rs now take an injected is_valid predicate so they're testable without depending on the global translation/language cache being populated.

Command bodies are now thin wrappers: fetch data, delegate to a pure build_reply/apply function, send the result.

Claude-Session: https://claude.ai/code/session_013FHY7jJsZpnLW8WQdcZgBg

claude added 2 commits July 6, 2026 16:47
Extracts each command's reply-building and validation logic out of
slash_commands.rs (which mixed business logic with ctx.send() calls)
into a new poise_impl/replies.rs module of pure functions and
Store-dependency-injected functions, then unit tests all of it: 85
tests covering all 11 commands, helpers.rs, BibleBooks, curated verse
selection, and chapter/verse text formatting. Adds a FakeStore
in-memory test double (store/fake.rs) so Store-backed behavior (prefs,
votd, daily verse role) is testable without a database, and a
test_support module for inspecting CreateReply embed content.

calc_translation/calc_lang in util/prefs.rs now take an injected
`is_valid` predicate so they're testable without depending on the
global translation/language cache being populated.

Command bodies are now thin wrappers: fetch data, delegate to a pure
build_*_reply/apply_* function, send the result.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013FHY7jJsZpnLW8WQdcZgBg
Resolves conflicts in slash_commands.rs between this branch's
reply-building extraction (replies.rs) and main's new Seed Bible
link/inline-detection settings and updated help text: kept the
extracted build_*_reply pattern and folded main's new "Open in Seed
Bible" chapter button into build_chapter_replies.

Also fixes two get_passage_url call sites (chapter command and
handler/message.rs) that were passing &String where Option<&str> was
expected, which meant main did not actually compile before this merge.

Adds the four new ServerPref trait methods introduced by main
(seed_bible_links_enabled, inline_detection_enabled) to FakeStore so
existing tests keep compiling, and extends build_chapter_replies'
tests to cover the new optional link button.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013FHY7jJsZpnLW8WQdcZgBg
@KallynGowdy
KallynGowdy merged commit 65d952c into main Jul 6, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants