loadTestCases loads test cases from a JSON file, optionally filtering by test case name
(filename string, testCaseName string)
| 100 | |
| 101 | // loadTestCases loads test cases from a JSON file, optionally filtering by test case name |
| 102 | func 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 |
| 136 | func printAgentSummary(report *models.AgentReport) { |