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

Function TestRepoMemoryMaxPatchSizeValidationArray

pkg/workflow/repo_memory_test.go:778–839  ·  view source on GitHub ↗

TestRepoMemoryMaxPatchSizeValidationArray tests max-patch-size validation in array notation

(t *testing.T)

Source from the content-addressed store, hash-verified

776
777// TestRepoMemoryMaxPatchSizeValidationArray tests max-patch-size validation in array notation
778func TestRepoMemoryMaxPatchSizeValidationArray(t *testing.T) {
779 tests := []struct {
780 name string
781 maxPatchSize int
782 wantError bool
783 errorText string
784 }{
785 {
786 name: "valid size in array",
787 maxPatchSize: 10240,
788 wantError: false,
789 },
790 {
791 name: "valid large size in array (500KB)",
792 maxPatchSize: 512000,
793 wantError: false,
794 },
795 {
796 name: "invalid size in array (zero)",
797 maxPatchSize: 0,
798 wantError: true,
799 errorText: "max-patch-size must be between 1 and 1048576, got 0",
800 },
801 {
802 name: "invalid size in array (exceeds max)",
803 maxPatchSize: 1048577,
804 wantError: true,
805 errorText: "max-patch-size must be between 1 and 1048576, got 1048577",
806 },
807 }
808
809 for _, tt := range tests {
810 t.Run(tt.name, func(t *testing.T) {
811 toolsMap := map[string]any{
812 "repo-memory": []any{
813 map[string]any{
814 "id": "test",
815 "max-patch-size": tt.maxPatchSize,
816 },
817 },
818 }
819
820 toolsConfig, err := ParseToolsConfig(toolsMap)
821 require.NoError(t, err, "Should parse tools config")
822
823 compiler := NewCompiler()
824 config, err := compiler.extractRepoMemoryConfig(toolsConfig, "")
825
826 if tt.wantError {
827 require.Error(t, err, "Should return an error")
828 if err != nil {
829 assert.Contains(t, err.Error(), tt.errorText, "Error message should match")
830 }
831 } else {
832 require.NoError(t, err, "Should not return an error")
833 if config != nil && len(config.Memories) > 0 {
834 assert.Equal(t, tt.maxPatchSize, config.Memories[0].MaxPatchSize, "MaxPatchSize should match")
835 }

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected