mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-13 22:15:33 +00:00
fix(env): address all PR review feedback
- Add settings profiles to zsh env completion (was proxy-only) - Document intentional ANTHROPIC_MODEL omission in transformToOpenAI - Use getCcsDir() in error hint instead of hardcoded ~/.ccs/ - Export parseFlag and add 5 unit tests for flag parsing - Add fish and PowerShell single-quote escaping tests
This commit is contained in:
1 parent
041e1c6cc2
commit
44b3152d34
3 files changed
+45
-5
No files matched your search
@@ -4,7 +4,12 @@
|
||||
* Tests pure utility functions: detectShell, formatExportLine, transformToOpenAI
|
||||
*/
|
||||
import { describe, it, expect, afterEach } from 'bun:test';
|
||||
import { detectShell, formatExportLine, transformToOpenAI } from '../../../src/commands/env-command';
|
||||
import {
|
||||
detectShell,
|
||||
formatExportLine,
|
||||
transformToOpenAI,
|
||||
parseFlag,
|
||||
} from '../../../src/commands/env-command';
|
||||
|
||||
describe('env-command', () => {
|
||||
describe('detectShell', () => {
|
||||
@@ -91,6 +96,16 @@ describe('env-command', () => {
|
||||
"export TOKEN='safe$(whoami)'"
|
||||
);
|
||||
});
|
||||
|
||||
it('escapes single quotes in fish values', () => {
|
||||
expect(formatExportLine('fish', 'VAL', "it's here")).toBe("set -gx VAL 'it\\'s here'");
|
||||
});
|
||||
|
||||
it('escapes single quotes in powershell values', () => {
|
||||
expect(formatExportLine('powershell', 'VAL', "it's here")).toBe(
|
||||
"$env:VAL = 'it''s here'"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('transformToOpenAI', () => {
|
||||
@@ -131,4 +146,26 @@ describe('env-command', () => {
|
||||
expect(result['ANTHROPIC_MAX_TOKENS']).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('parseFlag', () => {
|
||||
it('parses --flag=value style', () => {
|
||||
expect(parseFlag(['--format=openai'], 'format')).toBe('openai');
|
||||
});
|
||||
|
||||
it('parses --flag value style', () => {
|
||||
expect(parseFlag(['--format', 'openai'], 'format')).toBe('openai');
|
||||
});
|
||||
|
||||
it('handles values containing =', () => {
|
||||
expect(parseFlag(['--format=key=val=ue'], 'format')).toBe('key=val=ue');
|
||||
});
|
||||
|
||||
it('returns undefined for missing flag', () => {
|
||||
expect(parseFlag(['--shell', 'bash'], 'format')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('does not consume next flag as value', () => {
|
||||
expect(parseFlag(['--format', '--shell'], 'format')).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user