test: cover dotenv parse, remove, and append helpers#10
Draft
cursor[bot] wants to merge 1 commit intomainfrom
Draft
test: cover dotenv parse, remove, and append helpers#10cursor[bot] wants to merge 1 commit intomainfrom
cursor[bot] wants to merge 1 commit intomainfrom
Conversation
Exercises validation errors, quoting/escaping, duplicate keys, and removeDotenvKey behavior used by secrets and file workspace flows.
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.
Summary
Adds Vitest coverage for
src/lib/dotenv-parse.ts, which backs.envhandling in the vault file workspace and tRPC secrets parsing.Risky behavior now covered
parseDotenv: comment/blank skipping, trimming, first=semantics, quoted values, CRLF.removeDotenvKey: removes lines that parse as the target key while preserving comments and blank structure.appendDotenvKey: validation (empty key,=in key,#prefix, newlines in key/value), duplicate key detection, when values are quoted vs unquoted, escaping of"and\inside quoted strings, trimming trailing whitespace before append.Test files
src/lib/dotenv-parse.test.tsWhy this reduces regression risk
This module encodes parsing and serialization rules for secrets stored as dotenv text. A mistake here can corrupt files, leak malformed lines, or allow invalid keys—high blast radius across UI and API. These tests pin the contract without snapshots or environment coupling.
Validation
npm run test(Vitest) — all tests pass; deterministic node environment.