MCPcopy Create free account
hub / github.com/github/gh-aw / TestRepoMemoryMaxFileSizeValidationArray

Function TestRepoMemoryMaxFileSizeValidationArray

pkg/workflow/repo_memory_test.go:444–511  ·  view source on GitHub ↗

TestRepoMemoryMaxFileSizeValidationArray tests max-file-size validation in array notation

(t *testing.T)

Source from the content-addressed store, hash-verified

442
443// TestRepoMemoryMaxFileSizeValidationArray tests max-file-size validation in array notation
444func TestRepoMemoryMaxFileSizeValidationArray(t *testing.T) {
445 tests := []struct {
446 name string
447 maxFileSize int
448 wantError bool
449 errorText string
450 }{
451 {
452 name: "valid size in array",
453 maxFileSize: 524288,
454 wantError: false,
455 },
456 {
457 name: "invalid size in array (zero)",
458 maxFileSize: 0,
459 wantError: true,
460 errorText: "max-file-size must be between 1 and 104857600, got 0",
461 },
462 {
463 name: "invalid size in array (exceeds max)",
464 maxFileSize: 104857601,
465 wantError: true,
466 errorText: "max-file-size must be between 1 and 104857600, got 104857601",
467 },
468 }
469
470 for _, tt := range tests {
471 t.Run(tt.name, func(t *testing.T) {
472 toolsMap := map[string]any{
473 "repo-memory": []any{
474 map[string]any{
475 "id": "test",
476 "max-file-size": tt.maxFileSize,
477 },
478 },
479 }
480
481 toolsConfig, err := ParseToolsConfig(toolsMap)
482 if err != nil {
483 t.Fatalf("Failed to parse tools config: %v", err)
484 }
485
486 compiler := NewCompiler()
487 config, err := compiler.extractRepoMemoryConfig(toolsConfig, "")
488
489 if tt.wantError {
490 if err == nil {
491 t.Errorf("Expected error, got nil")
492 } else if !strings.Contains(err.Error(), tt.errorText) {
493 t.Errorf("Expected error containing '%s', got '%s'", tt.errorText, err.Error())
494 }
495 } else {
496 if err != nil {
497 t.Errorf("Expected no error, got: %v", err)
498 }
499 if config == nil {
500 t.Fatal("Expected non-nil config")
501 }

Callers

nothing calls this directly

Calls 6

ParseToolsConfigFunction · 0.85
NewCompilerFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected