Skip to content

Commit eeac65d

Browse files
committed
DEV clean up
1 parent 3a120f3 commit eeac65d

File tree

4 files changed

+46
-4
lines changed

4 files changed

+46
-4
lines changed

src/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const runServer = async (options = OPTIONS, {
4949
running = false;
5050
console.log('PatternFly MCP server stopped');
5151
process.exit(0);
52+
5253
/*
5354
try {
5455
// Close the server first

tests/cli.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import { start, type ServerInstance } from '../src/index';
8-
import { OPTIONS, parseCliOptions, setOptions } from '../src/options';
8+
import { OPTIONS, parseCliOptions } from '../src/options';
99

1010
describe('CLI Functionality', () => {
1111
let originalArgv: string[];
@@ -26,7 +26,7 @@ describe('CLI Functionality', () => {
2626
}
2727
}
2828
serverInstances = [];
29-
29+
3030
// Restore original process.argv
3131
process.argv = originalArgv;
3232
});
@@ -42,6 +42,7 @@ describe('CLI Functionality', () => {
4242

4343
// Test start() with CLI options
4444
const server = await start(cliOptions);
45+
4546
serverInstances.push(server);
4647
expect(OPTIONS.docsHost).toBe(true);
4748
expect(server.isRunning()).toBe(true);
@@ -57,6 +58,7 @@ describe('CLI Functionality', () => {
5758

5859
// Test start() with CLI options
5960
const server = await start(cliOptions);
61+
6062
serverInstances.push(server);
6163
expect(OPTIONS.docsHost).toBe(false);
6264
expect(server.isRunning()).toBe(true);
@@ -72,6 +74,7 @@ describe('CLI Functionality', () => {
7274

7375
// Test start() with CLI options
7476
const server = await start(cliOptions);
77+
7578
serverInstances.push(server);
7679
expect(OPTIONS.docsHost).toBe(false);
7780
expect(server.isRunning()).toBe(true);
@@ -83,6 +86,7 @@ describe('CLI Functionality', () => {
8386
const cliOptions1 = parseCliOptions();
8487

8588
const server1 = await start(cliOptions1);
89+
8690
serverInstances.push(server1);
8791

8892
expect(cliOptions1.docsHost).toBe(true);
@@ -94,6 +98,7 @@ describe('CLI Functionality', () => {
9498
const cliOptions2 = parseCliOptions();
9599

96100
const server2 = await start(cliOptions2);
101+
97102
serverInstances.push(server2);
98103

99104
expect(cliOptions2.docsHost).toBe(false);

tests/programmatic.test.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('Programmatic API Usage', () => {
2727
}
2828
}
2929
serverInstances = [];
30-
30+
3131
// Restore original process.argv
3232
process.argv = originalArgv;
3333
});
@@ -38,17 +38,20 @@ describe('Programmatic API Usage', () => {
3838
const firstOptions: Partial<CliOptions> = { docsHost: true };
3939

4040
const server1 = await start(firstOptions);
41+
4142
serverInstances.push(server1);
4243

4344
expect(OPTIONS.docsHost).toBe(true);
4445
expect(OPTIONS.sessionId).toBeDefined();
4546
const firstSessionId = OPTIONS.sessionId;
47+
4648
expect(server1.isRunning()).toBe(true);
4749

4850
// Second start() call with different options
4951
const secondOptions: Partial<CliOptions> = { docsHost: false };
5052

5153
const server2 = await start(secondOptions);
54+
5255
serverInstances.push(server2);
5356

5457
expect(OPTIONS.docsHost).toBe(false);
@@ -58,6 +61,7 @@ describe('Programmatic API Usage', () => {
5861

5962
// Third start() call with no options
6063
const server3 = await start({});
64+
6165
serverInstances.push(server3);
6266

6367
expect(OPTIONS.docsHost).toBe(false);
@@ -71,20 +75,24 @@ describe('Programmatic API Usage', () => {
7175

7276
// Multiple calls with same options
7377
const server1 = await start(options);
78+
7479
serverInstances.push(server1);
7580
expect(OPTIONS.docsHost).toBe(true);
7681
expect(OPTIONS.sessionId).toBeDefined();
7782
const firstSessionId = OPTIONS.sessionId;
83+
7884
expect(server1.isRunning()).toBe(true);
7985

8086
const server2 = await start(options);
87+
8188
serverInstances.push(server2);
8289
expect(OPTIONS.docsHost).toBe(true);
8390
expect(OPTIONS.sessionId).toBeDefined();
8491
expect(OPTIONS.sessionId).not.toBe(firstSessionId);
8592
expect(server2.isRunning()).toBe(true);
8693

8794
const server3 = await start(options);
95+
8896
serverInstances.push(server3);
8997
expect(OPTIONS.docsHost).toBe(true);
9098
expect(OPTIONS.sessionId).toBeDefined();
@@ -97,14 +105,17 @@ describe('Programmatic API Usage', () => {
97105
const initialOptions: Partial<CliOptions> = { docsHost: true };
98106

99107
const server1 = await start(initialOptions);
108+
100109
serverInstances.push(server1);
101110
expect(OPTIONS.docsHost).toBe(true);
102111
expect(OPTIONS.sessionId).toBeDefined();
103112
const firstSessionId = OPTIONS.sessionId;
113+
104114
expect(server1.isRunning()).toBe(true);
105115

106116
// Call with empty options - this will reset to default value
107117
const server2 = await start({});
118+
108119
serverInstances.push(server2);
109120
expect(OPTIONS.docsHost).toBe(false); // Will reset to default
110121
expect(OPTIONS.sessionId).toBeDefined();
@@ -113,6 +124,7 @@ describe('Programmatic API Usage', () => {
113124

114125
// Call with undefined options - this will also reset to default value
115126
const server3 = await start(undefined as any);
127+
116128
serverInstances.push(server3);
117129
expect(OPTIONS.docsHost).toBe(false); // Will reset to default
118130
expect(OPTIONS.sessionId).toBeDefined();
@@ -125,25 +137,31 @@ describe('Programmatic API Usage', () => {
125137

126138
// First call
127139
const server1 = await start(options);
140+
128141
serverInstances.push(server1);
129142
const firstDocsHost = OPTIONS.docsHost;
130143
const firstSessionId = OPTIONS.sessionId;
144+
131145
expect(server1.isRunning()).toBe(true);
132146

133147
// Second call with different options
134148
const secondOptions: Partial<CliOptions> = { docsHost: false };
135149

136150
const server2 = await start(secondOptions);
151+
137152
serverInstances.push(server2);
138153
const secondDocsHost = OPTIONS.docsHost;
139154
const secondSessionId = OPTIONS.sessionId;
155+
140156
expect(server2.isRunning()).toBe(true);
141157

142158
// Third call with original options
143159
const server3 = await start(options);
160+
144161
serverInstances.push(server3);
145162
const thirdDocsHost = OPTIONS.docsHost;
146163
const thirdSessionId = OPTIONS.sessionId;
164+
147165
expect(server3.isRunning()).toBe(true);
148166

149167
// Verify values changed as expected
@@ -163,18 +181,24 @@ describe('Programmatic API Usage', () => {
163181

164182
// Start multiple calls concurrently
165183
const server1 = await start(options1);
184+
166185
serverInstances.push(server1);
167186
const firstSessionId = OPTIONS.sessionId;
187+
168188
expect(server1.isRunning()).toBe(true);
169189

170190
const server2 = await start(options2);
191+
171192
serverInstances.push(server2);
172193
const secondSessionId = OPTIONS.sessionId;
194+
173195
expect(server2.isRunning()).toBe(true);
174196

175197
const server3 = await start({});
198+
176199
serverInstances.push(server3);
177200
const thirdSessionId = OPTIONS.sessionId;
201+
178202
expect(server3.isRunning()).toBe(true);
179203

180204
// OPTIONS should reflect the last call
@@ -193,6 +217,7 @@ describe('Programmatic API Usage', () => {
193217
const firstOptions: Partial<CliOptions> = { docsHost: true };
194218

195219
const server1 = await start(firstOptions);
220+
196221
serverInstances.push(server1);
197222
expect(OPTIONS.docsHost).toBe(true);
198223
expect(server1.isRunning()).toBe(true);
@@ -201,12 +226,14 @@ describe('Programmatic API Usage', () => {
201226
const secondOptions: Partial<CliOptions> = { docsHost: false };
202227

203228
const server2 = await start(secondOptions);
229+
204230
serverInstances.push(server2);
205231
expect(OPTIONS.docsHost).toBe(false);
206232
expect(server2.isRunning()).toBe(true);
207233

208234
// Third call with no options
209235
const server3 = await start({});
236+
210237
serverInstances.push(server3);
211238
expect(OPTIONS.docsHost).toBe(false);
212239
expect(server3.isRunning()).toBe(true);
@@ -217,6 +244,7 @@ describe('Programmatic API Usage', () => {
217244

218245
// First call
219246
const server1 = await start(options);
247+
220248
serverInstances.push(server1);
221249
expect(OPTIONS.docsHost).toBe(true);
222250
expect(server1.isRunning()).toBe(true);
@@ -226,6 +254,7 @@ describe('Programmatic API Usage', () => {
226254

227255
// Second call with modified options
228256
const server2 = await start(options);
257+
229258
serverInstances.push(server2);
230259
expect(OPTIONS.docsHost).toBe(false);
231260
expect(server2.isRunning()).toBe(true);
@@ -237,14 +266,17 @@ describe('Programmatic API Usage', () => {
237266

238267
// Start multiple calls concurrently
239268
const server1 = await start(options1);
269+
240270
serverInstances.push(server1);
241271
expect(server1.isRunning()).toBe(true);
242272

243273
const server2 = await start(options2);
274+
244275
serverInstances.push(server2);
245276
expect(server2.isRunning()).toBe(true);
246277

247278
const server3 = await start({});
279+
248280
serverInstances.push(server3);
249281
expect(server3.isRunning()).toBe(true);
250282

@@ -259,6 +291,7 @@ describe('Programmatic API Usage', () => {
259291
const invalidOptions = { invalidProperty: 'value' } as any;
260292

261293
const server = await start(invalidOptions);
294+
262295
serverInstances.push(server);
263296

264297
// Should not throw and server should be running
@@ -268,11 +301,13 @@ describe('Programmatic API Usage', () => {
268301
it('should handle null/undefined options', async () => {
269302
// Test with null options
270303
const server1 = await start(null as any);
304+
271305
serverInstances.push(server1);
272306
expect(server1.isRunning()).toBe(true);
273307

274308
// Test with undefined options
275309
const server2 = await start(undefined as any);
310+
276311
serverInstances.push(server2);
277312
expect(server2.isRunning()).toBe(true);
278313
});
@@ -281,6 +316,7 @@ describe('Programmatic API Usage', () => {
281316
const emptyOptions = {};
282317

283318
const server = await start(emptyOptions);
319+
284320
serverInstances.push(server);
285321

286322
// Should not throw and server should be running

tests/utils/stdioClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export const startServer = async ({
149149
try {
150150
// Try graceful shutdown first
151151
proc.kill(signal);
152-
152+
153153
// Set a timeout to force kill if graceful shutdown doesn't work
154154
const forceKillTimer = setTimeout(() => {
155155
try {

0 commit comments

Comments
 (0)