Skip to content

test: add config module tests + resetConfig() - #28

Closed
TerminalGravity wants to merge 2 commits into
mainfrom
feat/config-tests-and-reset
Closed

test: add config module tests + resetConfig()#28
TerminalGravity wants to merge 2 commits into
mainfrom
feat/config-tests-and-reset

Conversation

@TerminalGravity

Copy link
Copy Markdown
Collaborator

Adds 17 tests for src/lib/config.ts covering:

  • Default config values when no .preflight/ dir or env vars
  • Config caching and resetConfig() cache invalidation
  • Env var overrides (PROMPT_DISCIPLINE_PROFILE, PREFLIGHT_RELATED, EMBEDDING_PROVIDER, OPENAI_API_KEY)
  • .preflight/config.yml loading and merging with defaults
  • .preflight/triage.yml loading
  • Env vars ignored when .preflight/ exists
  • Graceful handling of malformed YAML
  • getRelatedProjects() and hasPreflightConfig() helpers

Also exports resetConfig() from config module for test isolation and potential config hot-reload.

All 60 tests passing.

… and contracts

The README references .preflight/ config extensively but there were no
concrete example files to copy. This adds a ready-to-use examples/.preflight/
directory with annotated config.yml, triage.yml, and contracts/api.yml,
plus a README explaining how to use them.
- Add 17 tests covering config loading from .preflight/, env var
  overrides, caching, malformed YAML handling, and helper functions
- Export resetConfig() to clear cached config (needed for tests and
  potential config hot-reload)
- All 60 tests passing

@TerminalGravity TerminalGravity left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resetConfig() is exactly what was needed for test isolation. Mock strategy is solid.

One question: the test for 'ignores env vars when .preflight/ exists' — is that the intended behavior? If someone has both a config dir and env vars set, silently ignoring the env vars could be surprising. Might be worth a debug log or a note in the README.

@TerminalGravity

Copy link
Copy Markdown
Collaborator Author

Superseded by newer PRs.

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.

1 participant