Skip to content

test: cover dotenv parse, remove, and append helpers#10

Draft
cursor[bot] wants to merge 1 commit intomainfrom
cursor/missing-test-coverage-107e
Draft

test: cover dotenv parse, remove, and append helpers#10
cursor[bot] wants to merge 1 commit intomainfrom
cursor/missing-test-coverage-107e

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor bot commented Apr 6, 2026

Summary

Adds Vitest coverage for src/lib/dotenv-parse.ts, which backs .env handling 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

  • Added: src/lib/dotenv-parse.test.ts

Why 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.
Open in Web View Automation 

Exercises validation errors, quoting/escaping, duplicate keys, and
removeDotenvKey behavior used by secrets and file workspace flows.
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