mirror of
https://github.com/hanzo-go/sdk.git
synced 2026-11-20 20:13:42 +00:00
* chore: sync repo * release: 0.1.0-alpha.6 --------- Co-authored-by: Hanzo Dev <[email protected]>
203 lines
4.8 KiB
Go
203 lines
4.8 KiB
Go
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
|
|
package hanzoai_test
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/hanzoai/go-sdk"
|
|
"github.com/hanzoai/go-sdk/internal/testutil"
|
|
"github.com/hanzoai/go-sdk/option"
|
|
)
|
|
|
|
func TestBatchNewWithOptionalParams(t *testing.T) {
|
|
t.Skip("Mock server tests are disabled")
|
|
baseURL := "http://localhost:4010"
|
|
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
|
|
baseURL = envURL
|
|
}
|
|
if !testutil.CheckTestServer(t, baseURL) {
|
|
return
|
|
}
|
|
client := hanzoai.NewClient(
|
|
option.WithBaseURL(baseURL),
|
|
option.WithAPIKey("My API Key"),
|
|
)
|
|
_, err := client.Batches.New(context.TODO(), hanzoai.BatchNewParams{
|
|
Provider: hanzoai.F("provider"),
|
|
})
|
|
if err != nil {
|
|
var apierr *hanzoai.Error
|
|
if errors.As(err, &apierr) {
|
|
t.Log(string(apierr.DumpRequest(true)))
|
|
}
|
|
t.Fatalf("err should be nil: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
func TestBatchGetWithOptionalParams(t *testing.T) {
|
|
t.Skip("Mock server tests are disabled")
|
|
baseURL := "http://localhost:4010"
|
|
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
|
|
baseURL = envURL
|
|
}
|
|
if !testutil.CheckTestServer(t, baseURL) {
|
|
return
|
|
}
|
|
client := hanzoai.NewClient(
|
|
option.WithBaseURL(baseURL),
|
|
option.WithAPIKey("My API Key"),
|
|
)
|
|
_, err := client.Batches.Get(
|
|
context.TODO(),
|
|
"batch_id",
|
|
hanzoai.BatchGetParams{
|
|
Provider: hanzoai.F("provider"),
|
|
},
|
|
)
|
|
if err != nil {
|
|
var apierr *hanzoai.Error
|
|
if errors.As(err, &apierr) {
|
|
t.Log(string(apierr.DumpRequest(true)))
|
|
}
|
|
t.Fatalf("err should be nil: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
func TestBatchListWithOptionalParams(t *testing.T) {
|
|
t.Skip("Mock server tests are disabled")
|
|
baseURL := "http://localhost:4010"
|
|
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
|
|
baseURL = envURL
|
|
}
|
|
if !testutil.CheckTestServer(t, baseURL) {
|
|
return
|
|
}
|
|
client := hanzoai.NewClient(
|
|
option.WithBaseURL(baseURL),
|
|
option.WithAPIKey("My API Key"),
|
|
)
|
|
_, err := client.Batches.List(context.TODO(), hanzoai.BatchListParams{
|
|
After: hanzoai.F("after"),
|
|
Limit: hanzoai.F(int64(0)),
|
|
Provider: hanzoai.F("provider"),
|
|
})
|
|
if err != nil {
|
|
var apierr *hanzoai.Error
|
|
if errors.As(err, &apierr) {
|
|
t.Log(string(apierr.DumpRequest(true)))
|
|
}
|
|
t.Fatalf("err should be nil: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
func TestBatchCancelWithProvider(t *testing.T) {
|
|
t.Skip("Mock server tests are disabled")
|
|
baseURL := "http://localhost:4010"
|
|
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
|
|
baseURL = envURL
|
|
}
|
|
if !testutil.CheckTestServer(t, baseURL) {
|
|
return
|
|
}
|
|
client := hanzoai.NewClient(
|
|
option.WithBaseURL(baseURL),
|
|
option.WithAPIKey("My API Key"),
|
|
)
|
|
_, err := client.Batches.CancelWithProvider(
|
|
context.TODO(),
|
|
"provider",
|
|
"batch_id",
|
|
)
|
|
if err != nil {
|
|
var apierr *hanzoai.Error
|
|
if errors.As(err, &apierr) {
|
|
t.Log(string(apierr.DumpRequest(true)))
|
|
}
|
|
t.Fatalf("err should be nil: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
func TestBatchNewWithProvider(t *testing.T) {
|
|
t.Skip("Mock server tests are disabled")
|
|
baseURL := "http://localhost:4010"
|
|
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
|
|
baseURL = envURL
|
|
}
|
|
if !testutil.CheckTestServer(t, baseURL) {
|
|
return
|
|
}
|
|
client := hanzoai.NewClient(
|
|
option.WithBaseURL(baseURL),
|
|
option.WithAPIKey("My API Key"),
|
|
)
|
|
_, err := client.Batches.NewWithProvider(context.TODO(), "provider")
|
|
if err != nil {
|
|
var apierr *hanzoai.Error
|
|
if errors.As(err, &apierr) {
|
|
t.Log(string(apierr.DumpRequest(true)))
|
|
}
|
|
t.Fatalf("err should be nil: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
func TestBatchListWithProviderWithOptionalParams(t *testing.T) {
|
|
t.Skip("Mock server tests are disabled")
|
|
baseURL := "http://localhost:4010"
|
|
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
|
|
baseURL = envURL
|
|
}
|
|
if !testutil.CheckTestServer(t, baseURL) {
|
|
return
|
|
}
|
|
client := hanzoai.NewClient(
|
|
option.WithBaseURL(baseURL),
|
|
option.WithAPIKey("My API Key"),
|
|
)
|
|
_, err := client.Batches.ListWithProvider(
|
|
context.TODO(),
|
|
"provider",
|
|
hanzoai.BatchListWithProviderParams{
|
|
After: hanzoai.F("after"),
|
|
Limit: hanzoai.F(int64(0)),
|
|
},
|
|
)
|
|
if err != nil {
|
|
var apierr *hanzoai.Error
|
|
if errors.As(err, &apierr) {
|
|
t.Log(string(apierr.DumpRequest(true)))
|
|
}
|
|
t.Fatalf("err should be nil: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
func TestBatchGetWithProvider(t *testing.T) {
|
|
t.Skip("Mock server tests are disabled")
|
|
baseURL := "http://localhost:4010"
|
|
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
|
|
baseURL = envURL
|
|
}
|
|
if !testutil.CheckTestServer(t, baseURL) {
|
|
return
|
|
}
|
|
client := hanzoai.NewClient(
|
|
option.WithBaseURL(baseURL),
|
|
option.WithAPIKey("My API Key"),
|
|
)
|
|
_, err := client.Batches.GetWithProvider(
|
|
context.TODO(),
|
|
"provider",
|
|
"batch_id",
|
|
)
|
|
if err != nil {
|
|
var apierr *hanzoai.Error
|
|
if errors.As(err, &apierr) {
|
|
t.Log(string(apierr.DumpRequest(true)))
|
|
}
|
|
t.Fatalf("err should be nil: %s", err.Error())
|
|
}
|
|
}
|