File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 112112 });
113113})->with ('request methods ' );
114114
115+ test ('request object mismatched project error ' , function (string $ requestMethod ) {
116+ $ payload = Payload::list ('models ' );
117+
118+ $ response = new Response (401 , ['Content-Type ' => 'application/json; charset=utf-8 ' ], json_encode ([
119+ 'error ' => [
120+ 'message ' => 'OpenAI-Project header should match project for API key ' ,
121+ 'type ' => 'invalid_request_error ' ,
122+ 'code ' => 'mismatched_project ' ,
123+ 'param ' => null ,
124+ ],
125+ 'status ' => 401
126+ ]));
127+
128+ $ this ->client
129+ ->shouldReceive ('sendRequest ' )
130+ ->once ()
131+ ->andReturn ($ response );
132+
133+ expect (fn () => $ this ->http ->$ requestMethod ($ payload ))
134+ ->toThrow (function (ErrorException $ e ) {
135+ expect ($ e ->getMessage ())->toBe ('OpenAI-Project header should match project for API key ' )
136+ ->and ($ e ->getErrorMessage ())->toBe ('OpenAI-Project header should match project for API key ' )
137+ ->and ($ e ->getErrorCode ())->toBe ('mismatched_project ' )
138+ ->and ($ e ->getErrorType ())->toBe ('invalid_request_error ' )
139+ ->and ($ e ->getStatusCode ())->toBe (401 );
140+ });
141+ })->with ('request methods ' );
142+
115143test ('request object server errors ' , function () {
116144 $ payload = Payload::create ('completions ' , ['model ' => 'gpt-4 ' ]);
117145
You can’t perform that action at this time.
0 commit comments