Skip to content

Commit ddbc238

Browse files
committed
Cleanup, added test cases
1 parent 4622d81 commit ddbc238

9 files changed

+202
-495
lines changed

cli/scripts/cli-metadata-tests.js

Lines changed: 102 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,6 @@ async function runTests() {
300300
"tools/list",
301301
"--metadata",
302302
"client=test-client",
303-
"version=1.0.0",
304-
"environment=test",
305303
);
306304

307305
// Test 2: General metadata with resources/list
@@ -314,8 +312,6 @@ async function runTests() {
314312
"resources/list",
315313
"--metadata",
316314
"client=test-client",
317-
"version=1.0.0",
318-
"environment=test",
319315
);
320316

321317
// Test 3: General metadata with prompts/list
@@ -328,8 +324,6 @@ async function runTests() {
328324
"prompts/list",
329325
"--metadata",
330326
"client=test-client",
331-
"version=1.0.0",
332-
"environment=test",
333327
);
334328

335329
// Test 4: General metadata with resources/read
@@ -344,8 +338,6 @@ async function runTests() {
344338
"test://static/resource/1",
345339
"--metadata",
346340
"client=test-client",
347-
"version=1.0.0",
348-
"environment=test",
349341
);
350342

351343
// Test 5: General metadata with prompts/get
@@ -360,8 +352,6 @@ async function runTests() {
360352
"simple_prompt",
361353
"--metadata",
362354
"client=test-client",
363-
"version=1.0.0",
364-
"environment=test",
365355
);
366356

367357
console.log(
@@ -381,9 +371,7 @@ async function runTests() {
381371
"--tool-arg",
382372
"message=hello world",
383373
"--tool-metadata",
384-
"tool-client=test-tool-client",
385-
"tool-version=2.0.0",
386-
"tool-environment=test-tool",
374+
"client=test-client",
387375
);
388376

389377
// Test 7: Tool-specific metadata with complex tool
@@ -400,9 +388,7 @@ async function runTests() {
400388
"a=10",
401389
"b=20",
402390
"--tool-metadata",
403-
"operation=addition",
404-
"precision=integer",
405-
"validation=strict",
391+
"client=test-client",
406392
);
407393

408394
console.log(
@@ -423,32 +409,14 @@ async function runTests() {
423409
"message=hello world",
424410
"--metadata",
425411
"client=general-client",
426-
"version=1.0.0",
427-
"environment=general",
428412
"--tool-metadata",
429-
"client=tool-specific-client",
430-
"tool-version=2.0.0",
431-
"tool-environment=tool-specific",
413+
"client=test-client",
432414
);
433415

434416
console.log(
435417
`\n${colors.YELLOW}=== Running Metadata Parsing Tests ===${colors.NC}`,
436418
);
437419

438-
// Test 9: Metadata with string values
439-
await runBasicTest(
440-
"metadata_parsing_strings",
441-
TEST_CMD,
442-
...TEST_ARGS,
443-
"--cli",
444-
"--method",
445-
"tools/list",
446-
"--metadata",
447-
"string_value=hello world",
448-
'quoted_string="quoted value"',
449-
'empty_string=""',
450-
);
451-
452420
// Test 10: Metadata with numeric values (should be converted to strings)
453421
await runBasicTest(
454422
"metadata_parsing_numbers",
@@ -463,20 +431,7 @@ async function runTests() {
463431
"negative_value=-10",
464432
);
465433

466-
// Test 11: Metadata with boolean values (should be converted to strings)
467-
await runBasicTest(
468-
"metadata_parsing_booleans",
469-
TEST_CMD,
470-
...TEST_ARGS,
471-
"--cli",
472-
"--method",
473-
"tools/list",
474-
"--metadata",
475-
"true_value=true",
476-
"false_value=false",
477-
);
478-
479-
// Test 12: Metadata with JSON values (should be converted to strings)
434+
// Test 11: Metadata with JSON values (should be converted to strings)
480435
await runBasicTest(
481436
"metadata_parsing_json",
482437
TEST_CMD,
@@ -490,7 +445,7 @@ async function runTests() {
490445
'json_string="\\"quoted\\""',
491446
);
492447

493-
// Test 13: Metadata with special characters
448+
// Test 12: Metadata with special characters
494449
await runBasicTest(
495450
"metadata_parsing_special_chars",
496451
TEST_CMD,
@@ -508,7 +463,7 @@ async function runTests() {
508463
`\n${colors.YELLOW}=== Running Metadata Edge Cases ===${colors.NC}`,
509464
);
510465

511-
// Test 14: Single metadata entry
466+
// Test 13: Single metadata entry
512467
await runBasicTest(
513468
"metadata_single_entry",
514469
TEST_CMD,
@@ -520,7 +475,7 @@ async function runTests() {
520475
"single_key=single_value",
521476
);
522477

523-
// Test 15: Many metadata entries
478+
// Test 14: Many metadata entries
524479
await runBasicTest(
525480
"metadata_many_entries",
526481
TEST_CMD,
@@ -540,7 +495,7 @@ async function runTests() {
540495
`\n${colors.YELLOW}=== Running Metadata Error Cases ===${colors.NC}`,
541496
);
542497

543-
// Test 16: Invalid metadata format (missing equals)
498+
// Test 15: Invalid metadata format (missing equals)
544499
await runErrorTest(
545500
"metadata_error_invalid_format",
546501
TEST_CMD,
@@ -552,7 +507,7 @@ async function runTests() {
552507
"invalid_format_no_equals",
553508
);
554509

555-
// Test 17: Invalid tool-meta format (missing equals)
510+
// Test 16: Invalid tool-meta format (missing equals)
556511
await runErrorTest(
557512
"metadata_error_invalid_tool_meta_format",
558513
TEST_CMD,
@@ -568,11 +523,81 @@ async function runTests() {
568523
"invalid_format_no_equals",
569524
);
570525

526+
console.log(
527+
`\n${colors.YELLOW}=== Running Metadata Impact Tests ===${colors.NC}`,
528+
);
529+
530+
// Test 17: Test tool-specific metadata vs general metadata precedence
531+
await runBasicTest(
532+
"metadata_precedence_tool_overrides_general",
533+
TEST_CMD,
534+
...TEST_ARGS,
535+
"--cli",
536+
"--method",
537+
"tools/call",
538+
"--tool-name",
539+
"echo",
540+
"--tool-arg",
541+
"message=precedence test",
542+
"--metadata",
543+
"client=general-client",
544+
"--tool-metadata",
545+
"client=tool-specific-client",
546+
);
547+
548+
// Test 18: Test metadata with resources methods
549+
await runBasicTest(
550+
"metadata_resources_methods",
551+
TEST_CMD,
552+
...TEST_ARGS,
553+
"--cli",
554+
"--method",
555+
"resources/list",
556+
"--metadata",
557+
"resource_client=test-resource-client",
558+
);
559+
560+
// Test 19: Test metadata with prompts methods
561+
await runBasicTest(
562+
"metadata_prompts_methods",
563+
TEST_CMD,
564+
...TEST_ARGS,
565+
"--cli",
566+
"--method",
567+
"prompts/get",
568+
"--prompt-name",
569+
"simple_prompt",
570+
"--metadata",
571+
"prompt_client=test-prompt-client",
572+
);
573+
574+
console.log(
575+
`\n${colors.YELLOW}=== Running Metadata Validation Tests ===${colors.NC}`,
576+
);
577+
578+
// Test 20: Test metadata with special characters in keys
579+
await runBasicTest(
580+
"metadata_special_key_characters",
581+
TEST_CMD,
582+
...TEST_ARGS,
583+
"--cli",
584+
"--method",
585+
"tools/call",
586+
"--tool-name",
587+
"echo",
588+
"--tool-arg",
589+
"message=special keys test",
590+
"--metadata",
591+
"key-with-dashes=value1",
592+
"key_with_underscores=value2",
593+
"key.with.dots=value3",
594+
);
595+
571596
console.log(
572597
`\n${colors.YELLOW}=== Running Metadata Integration Tests ===${colors.NC}`,
573598
);
574599

575-
// Test 18: Metadata with all MCP methods
600+
// Test 21: Metadata with all MCP methods
576601
await runBasicTest(
577602
"metadata_integration_all_methods",
578603
TEST_CMD,
@@ -585,7 +610,7 @@ async function runTests() {
585610
"test_phase=all_methods",
586611
);
587612

588-
// Test 19: Complex metadata scenario
613+
// Test 22: Complex metadata scenario
589614
await runBasicTest(
590615
"metadata_complex_scenario",
591616
TEST_CMD,
@@ -608,6 +633,27 @@ async function runTests() {
608633
"priority=high",
609634
);
610635

636+
// Test 23: Metadata parsing validation test
637+
await runBasicTest(
638+
"metadata_parsing_validation",
639+
TEST_CMD,
640+
...TEST_ARGS,
641+
"--cli",
642+
"--method",
643+
"tools/call",
644+
"--tool-name",
645+
"echo",
646+
"--tool-arg",
647+
"message=parsing validation test",
648+
"--metadata",
649+
"valid_key=valid_value",
650+
"numeric_key=123",
651+
"boolean_key=true",
652+
'json_key=\'{"test":"value"}\'',
653+
"special_key=!@#$%^&*()",
654+
"unicode_key=🚀🎉✨",
655+
);
656+
611657
// Print test summary
612658
console.log(`\n${colors.YELLOW}=== Test Summary ===${colors.NC}`);
613659
console.log(`${colors.GREEN}Passed: ${PASSED_TESTS}${colors.NC}`);

cli/scripts/metadata-test-output/metadata_empty.log

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)