|
3 | 3 | use Illuminate\Support\Facades\File; |
4 | 4 | use Illuminate\Support\Facades\Process; |
5 | 5 | use Laravel\AiAssistant\Mcp\Tools\LogReader; |
6 | | -use Laravel\Mcp\Tools\ToolResponse; |
| 6 | +use Laravel\Mcp\Tools\ToolResult; |
7 | 7 |
|
8 | 8 | it('calls process with the correct log path when one is provided', function () { |
9 | 9 | Process::fake([ |
|
15 | 15 |
|
16 | 16 | $tool = new LogReader(); |
17 | 17 |
|
18 | | - $tool->handle([ |
| 18 | + $result =$tool->handle([ |
19 | 19 | 'lines' => 10, |
20 | 20 | 'log_path' => 'my/custom/log.log', |
21 | 21 | ]); |
|
114 | 114 | ]); |
115 | 115 |
|
116 | 116 | $logPath = storage_path('logs/laravel.log'); |
117 | | - expect($response)->toEqual(new ToolResponse("Log file not found or is not readable: {$logPath}")); |
| 117 | + expect($response)->toEqual(ToolResult::error("Log file not found or is not readable: {$logPath}")); |
118 | 118 | }); |
119 | 119 |
|
120 | 120 | it('returns an error if the log file is not readable', function () { |
|
127 | 127 | ]); |
128 | 128 |
|
129 | 129 | $logPath = storage_path('logs/laravel.log'); |
130 | | - expect($response)->toEqual(new ToolResponse("Log file not found or is not readable: {$logPath}")); |
| 130 | + expect($response)->toEqual(ToolResult::error("Log file not found or is not readable: {$logPath}")); |
131 | 131 | }); |
132 | 132 |
|
133 | 133 | it('returns an error if the process fails', function () { |
|
147 | 147 | 'lines' => 10, |
148 | 148 | ]); |
149 | 149 |
|
150 | | - expect($response)->toEqual(new ToolResponse("Failed to read log file. Error: Something went wrong")); |
| 150 | + expect($response)->toEqual(ToolResult::error("Failed to read log file. Error: Something went wrong")); |
151 | 151 | }); |
152 | 152 |
|
153 | 153 | it('returns a message if no log entries match the grep pattern', function () { |
|
164 | 164 | 'grep' => 'non_existent_pattern', |
165 | 165 | ]); |
166 | 166 |
|
167 | | - expect($response)->toEqual(new ToolResponse("No log entries found matching pattern: non_existent_pattern")); |
| 167 | + expect($response)->toEqual(ToolResult::error("No log entries found matching pattern: non_existent_pattern")); |
168 | 168 | }); |
169 | 169 |
|
170 | 170 | it('returns a message if the log file is empty', function () { |
|
180 | 180 | 'lines' => 10, |
181 | 181 | ]); |
182 | 182 |
|
183 | | - expect($response)->toEqual(new ToolResponse('Log file is empty or no entries found.')); |
| 183 | + expect($response)->toEqual(ToolResult::error('Log file is empty or no entries found.')); |
184 | 184 | }); |
185 | 185 |
|
186 | 186 | it('returns the log content on success', function () { |
|
196 | 196 | 'lines' => 10, |
197 | 197 | ]); |
198 | 198 |
|
199 | | - expect($response)->toEqual(new ToolResponse("log line 1 \n log line 2")); |
| 199 | + expect($response)->toEqual(ToolResult::text("log line 1 \n log line 2")); |
200 | 200 | }); |
0 commit comments