Skip to content

Commit

Permalink
Add test for invoking non-existant APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Oct 19, 2024
1 parent eb8897c commit ae9f872
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/main/php/com/openai/rest/OpenAIEndpoint.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
use util\log\Traceable;
use webservices\rest\Endpoint;

/** @test com.openai.unittest.OpenAIEndpointTest */
/**
* OpenAI REST API endpoint
*
* @test com.openai.unittest.OpenAIEndpointTest
*/
class OpenAIEndpoint implements Traceable {
private $endpoint;

Expand Down
11 changes: 9 additions & 2 deletions src/test/php/com/openai/unittest/OpenAIEndpointTest.class.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php namespace com\openai\unittest;

use com\openai\rest\OpenAIEndpoint;
use test\{Assert, Test};
use webservices\rest\TestEndpoint;
use test\{Assert, Expect, Test};
use util\log\{LogCategory, BufferedAppender};
use webservices\rest\{TestEndpoint, UnexpectedStatus};

class OpenAIEndpointTest {
const URI= 'https://[email protected]/v1';
Expand Down Expand Up @@ -50,4 +51,10 @@ public function stream() {
$endpoint->api('/chat/completions')->stream(['stream' => true])->result()
);
}

#[Test, Expect(UnexpectedStatus::class)]
public function invoke_non_existant_api() {
$endpoint= new OpenAIEndpoint($this->testingEndpoint());
$endpoint->api('/non-exisant')->invoke([]);
}
}

0 comments on commit ae9f872

Please sign in to comment.