forked from MiniMax-AI/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset.test.ts
More file actions
138 lines (128 loc) · 3.22 KB
/
Copy pathset.test.ts
File metadata and controls
138 lines (128 loc) · 3.22 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import { describe, it, expect, mock } from 'bun:test';
import { default as setCommand } from '../../../src/commands/config/set';
// Mock file I/O
mock.module('../../../src/config/loader', () => ({
readConfigFile: () => ({}),
writeConfigFile: mock(() => Promise.resolve()),
}));
describe('config set command', () => {
it('has correct name', () => {
expect(setCommand.name).toBe('config set');
});
it('requires key and value', async () => {
const config = {
region: 'global' as const,
baseUrl: 'https://api.mmx.io',
output: 'text' as const,
timeout: 10,
verbose: false,
quiet: false,
noColor: true,
yes: false,
dryRun: false,
nonInteractive: true,
async: false,
};
await expect(
setCommand.execute(config, {
quiet: false,
verbose: false,
noColor: true,
yes: false,
dryRun: false,
help: false,
nonInteractive: true,
async: false,
}),
).rejects.toThrow('--key and --value are required');
});
it('validates config key', async () => {
const config = {
region: 'global' as const,
baseUrl: 'https://api.mmx.io',
output: 'text' as const,
timeout: 10,
verbose: false,
quiet: false,
noColor: true,
yes: false,
dryRun: false,
nonInteractive: true,
async: false,
};
await expect(
setCommand.execute(config, {
key: 'invalid_key',
value: 'test',
quiet: false,
verbose: false,
noColor: true,
yes: false,
dryRun: false,
help: false,
nonInteractive: true,
async: false,
}),
).rejects.toThrow('Invalid config key');
});
it('accepts default_text_model key', async () => {
const config = {
region: 'global' as const,
baseUrl: 'https://api.mmx.io',
output: 'text' as const,
timeout: 10,
verbose: false,
quiet: false,
noColor: true,
yes: false,
dryRun: true,
nonInteractive: true,
async: false,
};
// Should not throw — key is valid
await expect(
setCommand.execute(config, {
key: 'default_text_model',
value: 'MiniMax-M2.7-highspeed',
quiet: false,
verbose: false,
noColor: true,
yes: false,
dryRun: true,
help: false,
nonInteractive: true,
async: false,
}),
).resolves.toBeUndefined();
});
it('accepts hyphen alias default-text-model', async () => {
const config = {
region: 'global' as const,
baseUrl: 'https://api.mmx.io',
output: 'text' as const,
timeout: 10,
verbose: false,
quiet: false,
noColor: true,
yes: false,
dryRun: true,
nonInteractive: true,
async: false,
};
// Hyphen alias should resolve to default_text_model
await expect(
setCommand.execute(config, {
key: 'default-text-model',
value: 'MiniMax-M2.7-highspeed',
quiet: false,
verbose: false,
noColor: true,
yes: false,
dryRun: true,
help: false,
nonInteractive: true,
async: false,
}),
).resolves.toBeUndefined();
});
});