Files
sdk/customer_test.go
7758be4af2 release: 0.1.0-alpha.6 (#16)
* chore: sync repo

* release: 0.1.0-alpha.6

---------

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-08 18:10:23 -07:00

217 lines
5.9 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 TestCustomerNewWithOptionalParams(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.Customer.New(context.TODO(), hanzoai.CustomerNewParams{
UserID: hanzoai.F("user_id"),
Alias: hanzoai.F("alias"),
AllowedModelRegion: hanzoai.F(hanzoai.CustomerNewParamsAllowedModelRegionEu),
Blocked: hanzoai.F(true),
BudgetDuration: hanzoai.F("budget_duration"),
BudgetID: hanzoai.F("budget_id"),
DefaultModel: hanzoai.F("default_model"),
MaxBudget: hanzoai.F(0.000000),
MaxParallelRequests: hanzoai.F(int64(0)),
ModelMaxBudget: hanzoai.F(map[string]hanzoai.CustomerNewParamsModelMaxBudget{
"foo": {
BudgetDuration: hanzoai.F("budget_duration"),
MaxBudget: hanzoai.F(0.000000),
RpmLimit: hanzoai.F(int64(0)),
TpmLimit: hanzoai.F(int64(0)),
},
}),
RpmLimit: hanzoai.F(int64(0)),
SoftBudget: hanzoai.F(0.000000),
TpmLimit: 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 TestCustomerUpdateWithOptionalParams(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.Customer.Update(context.TODO(), hanzoai.CustomerUpdateParams{
UserID: hanzoai.F("user_id"),
Alias: hanzoai.F("alias"),
AllowedModelRegion: hanzoai.F(hanzoai.CustomerUpdateParamsAllowedModelRegionEu),
Blocked: hanzoai.F(true),
BudgetID: hanzoai.F("budget_id"),
DefaultModel: hanzoai.F("default_model"),
MaxBudget: hanzoai.F(0.000000),
})
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 TestCustomerList(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.Customer.List(context.TODO())
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 TestCustomerDelete(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.Customer.Delete(context.TODO(), hanzoai.CustomerDeleteParams{
UserIDs: hanzoai.F([]string{"string"}),
})
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 TestCustomerBlock(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.Customer.Block(context.TODO(), hanzoai.CustomerBlockParams{
BlockUsers: hanzoai.BlockUsersParam{
UserIDs: hanzoai.F([]string{"string"}),
},
})
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 TestCustomerGetInfo(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.Customer.GetInfo(context.TODO(), hanzoai.CustomerGetInfoParams{
EndUserID: hanzoai.F("end_user_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 TestCustomerUnblock(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.Customer.Unblock(context.TODO(), hanzoai.CustomerUnblockParams{
BlockUsers: hanzoai.BlockUsersParam{
UserIDs: hanzoai.F([]string{"string"}),
},
})
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())
}
}