Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrTestErrorAccumulatorWriteFailed = errors.New("test error accumulator failed")
)
Functions ¶
func CreateTestDirectory ¶
CreateTestDirectory creates a temporary folder which will be deleted when cleanup is called.
func CreateTestFile ¶
CreateTestFile creates a fake file with "hello" as the content.
func GetTestToken ¶
func GetTestToken() string
Types ¶
type FailingErrorBuffer ¶
type FailingErrorBuffer struct{}
func (*FailingErrorBuffer) Bytes ¶
func (b *FailingErrorBuffer) Bytes() []byte
func (*FailingErrorBuffer) Len ¶
func (b *FailingErrorBuffer) Len() int
type ServerTest ¶
type ServerTest struct {
// contains filtered or unexported fields
}
func NewTestServer ¶
func NewTestServer() *ServerTest
func (*ServerTest) OpenAITestServer ¶
func (ts *ServerTest) OpenAITestServer() *httptest.Server
OpenAITestServer Creates a mocked OpenAI server which can pretend to handle requests during testing.
func (*ServerTest) RegisterHandler ¶
func (ts *ServerTest) RegisterHandler(path string, handler handler)
type TokenRoundTripper ¶
type TokenRoundTripper struct { Token string Fallback http.RoundTripper }
TokenRoundTripper is a struct that implements the RoundTripper interface, specifically to handle the authentication token by adding a token to the request header. We need this because the API requires that each request include a valid API token in the headers for authentication and authorization.
func (*TokenRoundTripper) RoundTrip ¶
RoundTrip takes an *http.Request as input and returns an *http.Response and an error.
It is expected to use the provided request to create a connection to an HTTP server and return the response, or an error if one occurred. The returned Response should have its Body closed. If the RoundTrip method returns an error, the Client's Get, Head, Post, and PostForm methods return the same error.