MCPcopy Create free account
hub / github.com/docker/model-test / loadTestCases

Function loadTestCases

main.go:102–133  ·  view source on GitHub ↗

loadTestCases loads test cases from a JSON file, optionally filtering by test case name

(filename string, testCaseName string)

Source from the content-addressed store, hash-verified

100
101// loadTestCases loads test cases from a JSON file, optionally filtering by test case name
102func loadTestCases(filename string, testCaseName string) ([]models.TestCase, error) {
103 data, err := os.ReadFile(filename)
104 if err != nil {
105 return nil, fmt.Errorf("failed to read test cases file: %w", err)
106 }
107
108 var allTestCases []models.TestCase
109 if err := json.Unmarshal(data, &allTestCases); err != nil {
110 return nil, fmt.Errorf("failed to parse test cases: %w", err)
111 }
112
113 // If no specific test case is requested, return all test cases
114 if testCaseName == "" {
115 return allTestCases, nil
116 }
117
118 // Filter for the specific test case
119 var filteredTestCases []models.TestCase
120 for _, testCase := range allTestCases {
121 if testCase.Name == testCaseName {
122 filteredTestCases = append(filteredTestCases, testCase)
123 break
124 }
125 }
126
127 // Validate that the test case was found
128 if len(filteredTestCases) == 0 {
129 return nil, fmt.Errorf("test case '%s' not found in configuration file", testCaseName)
130 }
131
132 return filteredTestCases, nil
133}
134
135// printAgentSummary prints a summary of the agent test results
136func printAgentSummary(report *models.AgentReport) {

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected