test(learn): cover the learn module's progress and workspace lifecycle#819
Merged
Conversation
src/learn.sh (1.2k lines, 82 functions) had no tests at all. Cover its non-interactive core: mark_completed/is_completed persistence (roundtrip, exact-match so lesson_1 does not shadow lesson_10, accumulation, absent progress file) and init/cleanup workspace lifecycle (including cleanup without init). LEARN_PROGRESS_FILE is a readonly resolved from $HOME at source time, so each test sources learn.sh in a fresh shell with HOME pointed at a sandbox — the user's real progress file is never touched, and the tests are parallel-safe.
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.
🤔 Background
src/learn.sh(1.2k lines, 82 functions) was the only module with no tests at all — a static gap scan of public functions vs test references surfaced it.💡 Changes
tests/unit/learn_test.shcovering the non-interactive core: progress persistence (mark_completed/is_completedroundtrip, exact lesson matching, accumulation, absent file) and theinit/cleanupworkspace lifecycle.learn.shin a fresh shell withHOMEsandboxed (the progress-file path is a readonly bound at source time), so the user's real progress file is never touched and the tests are parallel-safe.