forked from cppalliance/pinecone-read-only-mcp-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.test.ts
More file actions
47 lines (42 loc) · 1.49 KB
/
Copy pathcli.test.ts
File metadata and controls
47 lines (42 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { describe, expect, it } from 'vitest';
import { parseCli } from './cli.js';
describe('parseCli', () => {
it('does not treat a following flag as a value for --api-key', () => {
const r = parseCli(['--api-key', '--index-name', 'my-index']);
expect(r.kind).toBe('config');
if (r.kind === 'config') {
expect(r.overrides.apiKey).toBeUndefined();
expect(r.overrides.indexName).toBe('my-index');
}
});
it('parses --api-key with a real value', () => {
const r = parseCli(['--api-key', 'sk-test', '--index-name', 'idx']);
expect(r.kind).toBe('config');
if (r.kind === 'config') {
expect(r.overrides.apiKey).toBe('sk-test');
expect(r.overrides.indexName).toBe('idx');
}
});
it('does not consume --top-k when the next token is another flag', () => {
const r = parseCli(['--top-k', '--log-level', 'DEBUG']);
expect(r.kind).toBe('config');
if (r.kind === 'config') {
expect(r.overrides.defaultTopK).toBeUndefined();
expect(r.overrides.logLevel).toBe('DEBUG');
}
});
it('parses numeric --top-k when value is valid', () => {
const r = parseCli(['--top-k', '25']);
expect(r.kind).toBe('config');
if (r.kind === 'config') {
expect(r.overrides.defaultTopK).toBe(25);
}
});
it('parses --disable-remote-schema', () => {
const r = parseCli(['--disable-remote-schema']);
expect(r.kind).toBe('config');
if (r.kind === 'config') {
expect(r.overrides.disableRemoteSchema).toBe(true);
}
});
});