Add unit tests for every Discord command - #22
Merged
Merged
Conversation
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
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.
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_validpredicate 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