Skip to content

Commit d8c65d2

Browse files
chore: add request options to client tests (#321)
1 parent 58abd55 commit d8c65d2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

client_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ func (t *closureTransport) RoundTrip(req *http.Request) (*http.Response, error)
2828
func TestUserAgentHeader(t *testing.T) {
2929
var userAgent string
3030
client := openai.NewClient(
31+
option.WithAPIKey("My API Key"),
3132
option.WithHTTPClient(&http.Client{
3233
Transport: &closureTransport{
3334
fn: func(req *http.Request) (*http.Response, error) {
@@ -57,6 +58,7 @@ func TestUserAgentHeader(t *testing.T) {
5758
func TestRetryAfter(t *testing.T) {
5859
retryCountHeaders := make([]string, 0)
5960
client := openai.NewClient(
61+
option.WithAPIKey("My API Key"),
6062
option.WithHTTPClient(&http.Client{
6163
Transport: &closureTransport{
6264
fn: func(req *http.Request) (*http.Response, error) {
@@ -99,6 +101,7 @@ func TestRetryAfter(t *testing.T) {
99101
func TestDeleteRetryCountHeader(t *testing.T) {
100102
retryCountHeaders := make([]string, 0)
101103
client := openai.NewClient(
104+
option.WithAPIKey("My API Key"),
102105
option.WithHTTPClient(&http.Client{
103106
Transport: &closureTransport{
104107
fn: func(req *http.Request) (*http.Response, error) {
@@ -137,6 +140,7 @@ func TestDeleteRetryCountHeader(t *testing.T) {
137140
func TestOverwriteRetryCountHeader(t *testing.T) {
138141
retryCountHeaders := make([]string, 0)
139142
client := openai.NewClient(
143+
option.WithAPIKey("My API Key"),
140144
option.WithHTTPClient(&http.Client{
141145
Transport: &closureTransport{
142146
fn: func(req *http.Request) (*http.Response, error) {
@@ -175,6 +179,7 @@ func TestOverwriteRetryCountHeader(t *testing.T) {
175179
func TestRetryAfterMs(t *testing.T) {
176180
attempts := 0
177181
client := openai.NewClient(
182+
option.WithAPIKey("My API Key"),
178183
option.WithHTTPClient(&http.Client{
179184
Transport: &closureTransport{
180185
fn: func(req *http.Request) (*http.Response, error) {
@@ -209,6 +214,7 @@ func TestRetryAfterMs(t *testing.T) {
209214

210215
func TestContextCancel(t *testing.T) {
211216
client := openai.NewClient(
217+
option.WithAPIKey("My API Key"),
212218
option.WithHTTPClient(&http.Client{
213219
Transport: &closureTransport{
214220
fn: func(req *http.Request) (*http.Response, error) {
@@ -237,6 +243,7 @@ func TestContextCancel(t *testing.T) {
237243

238244
func TestContextCancelDelay(t *testing.T) {
239245
client := openai.NewClient(
246+
option.WithAPIKey("My API Key"),
240247
option.WithHTTPClient(&http.Client{
241248
Transport: &closureTransport{
242249
fn: func(req *http.Request) (*http.Response, error) {
@@ -273,6 +280,7 @@ func TestContextDeadline(t *testing.T) {
273280

274281
go func() {
275282
client := openai.NewClient(
283+
option.WithAPIKey("My API Key"),
276284
option.WithHTTPClient(&http.Client{
277285
Transport: &closureTransport{
278286
fn: func(req *http.Request) (*http.Response, error) {
@@ -318,6 +326,7 @@ func TestContextDeadlineStreaming(t *testing.T) {
318326

319327
go func() {
320328
client := openai.NewClient(
329+
option.WithAPIKey("My API Key"),
321330
option.WithHTTPClient(&http.Client{
322331
Transport: &closureTransport{
323332
fn: func(req *http.Request) (*http.Response, error) {
@@ -371,6 +380,7 @@ func TestContextDeadlineStreamingWithRequestTimeout(t *testing.T) {
371380

372381
go func() {
373382
client := openai.NewClient(
383+
option.WithAPIKey("My API Key"),
374384
option.WithHTTPClient(&http.Client{
375385
Transport: &closureTransport{
376386
fn: func(req *http.Request) (*http.Response, error) {

0 commit comments

Comments
 (0)