mirror of
https://github.com/openai/openai-go.git
synced 2026-04-01 17:17:14 +09:00
chore: add request options to client tests (#321)
This commit is contained in:
@@ -28,6 +28,7 @@ func (t *closureTransport) RoundTrip(req *http.Request) (*http.Response, error)
|
||||
func TestUserAgentHeader(t *testing.T) {
|
||||
var userAgent string
|
||||
client := openai.NewClient(
|
||||
option.WithAPIKey("My API Key"),
|
||||
option.WithHTTPClient(&http.Client{
|
||||
Transport: &closureTransport{
|
||||
fn: func(req *http.Request) (*http.Response, error) {
|
||||
@@ -57,6 +58,7 @@ func TestUserAgentHeader(t *testing.T) {
|
||||
func TestRetryAfter(t *testing.T) {
|
||||
retryCountHeaders := make([]string, 0)
|
||||
client := openai.NewClient(
|
||||
option.WithAPIKey("My API Key"),
|
||||
option.WithHTTPClient(&http.Client{
|
||||
Transport: &closureTransport{
|
||||
fn: func(req *http.Request) (*http.Response, error) {
|
||||
@@ -99,6 +101,7 @@ func TestRetryAfter(t *testing.T) {
|
||||
func TestDeleteRetryCountHeader(t *testing.T) {
|
||||
retryCountHeaders := make([]string, 0)
|
||||
client := openai.NewClient(
|
||||
option.WithAPIKey("My API Key"),
|
||||
option.WithHTTPClient(&http.Client{
|
||||
Transport: &closureTransport{
|
||||
fn: func(req *http.Request) (*http.Response, error) {
|
||||
@@ -137,6 +140,7 @@ func TestDeleteRetryCountHeader(t *testing.T) {
|
||||
func TestOverwriteRetryCountHeader(t *testing.T) {
|
||||
retryCountHeaders := make([]string, 0)
|
||||
client := openai.NewClient(
|
||||
option.WithAPIKey("My API Key"),
|
||||
option.WithHTTPClient(&http.Client{
|
||||
Transport: &closureTransport{
|
||||
fn: func(req *http.Request) (*http.Response, error) {
|
||||
@@ -175,6 +179,7 @@ func TestOverwriteRetryCountHeader(t *testing.T) {
|
||||
func TestRetryAfterMs(t *testing.T) {
|
||||
attempts := 0
|
||||
client := openai.NewClient(
|
||||
option.WithAPIKey("My API Key"),
|
||||
option.WithHTTPClient(&http.Client{
|
||||
Transport: &closureTransport{
|
||||
fn: func(req *http.Request) (*http.Response, error) {
|
||||
@@ -209,6 +214,7 @@ func TestRetryAfterMs(t *testing.T) {
|
||||
|
||||
func TestContextCancel(t *testing.T) {
|
||||
client := openai.NewClient(
|
||||
option.WithAPIKey("My API Key"),
|
||||
option.WithHTTPClient(&http.Client{
|
||||
Transport: &closureTransport{
|
||||
fn: func(req *http.Request) (*http.Response, error) {
|
||||
@@ -237,6 +243,7 @@ func TestContextCancel(t *testing.T) {
|
||||
|
||||
func TestContextCancelDelay(t *testing.T) {
|
||||
client := openai.NewClient(
|
||||
option.WithAPIKey("My API Key"),
|
||||
option.WithHTTPClient(&http.Client{
|
||||
Transport: &closureTransport{
|
||||
fn: func(req *http.Request) (*http.Response, error) {
|
||||
@@ -273,6 +280,7 @@ func TestContextDeadline(t *testing.T) {
|
||||
|
||||
go func() {
|
||||
client := openai.NewClient(
|
||||
option.WithAPIKey("My API Key"),
|
||||
option.WithHTTPClient(&http.Client{
|
||||
Transport: &closureTransport{
|
||||
fn: func(req *http.Request) (*http.Response, error) {
|
||||
@@ -318,6 +326,7 @@ func TestContextDeadlineStreaming(t *testing.T) {
|
||||
|
||||
go func() {
|
||||
client := openai.NewClient(
|
||||
option.WithAPIKey("My API Key"),
|
||||
option.WithHTTPClient(&http.Client{
|
||||
Transport: &closureTransport{
|
||||
fn: func(req *http.Request) (*http.Response, error) {
|
||||
@@ -371,6 +380,7 @@ func TestContextDeadlineStreamingWithRequestTimeout(t *testing.T) {
|
||||
|
||||
go func() {
|
||||
client := openai.NewClient(
|
||||
option.WithAPIKey("My API Key"),
|
||||
option.WithHTTPClient(&http.Client{
|
||||
Transport: &closureTransport{
|
||||
fn: func(req *http.Request) (*http.Response, error) {
|
||||
|
||||
Reference in New Issue
Block a user