Files
sdk/spend_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

97 lines
2.6 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 TestSpendCalculateSpendWithOptionalParams(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.Spend.CalculateSpend(context.TODO(), hanzoai.SpendCalculateSpendParams{
CompletionResponse: hanzoai.F[any](map[string]interface{}{}),
Messages: hanzoai.F([]interface{}{map[string]interface{}{}}),
Model: hanzoai.F("model"),
})
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 TestSpendListLogsWithOptionalParams(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.Spend.ListLogs(context.TODO(), hanzoai.SpendListLogsParams{
APIKey: hanzoai.F("api_key"),
EndDate: hanzoai.F("end_date"),
RequestID: hanzoai.F("request_id"),
StartDate: hanzoai.F("start_date"),
UserID: hanzoai.F("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 TestSpendListTagsWithOptionalParams(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.Spend.ListTags(context.TODO(), hanzoai.SpendListTagsParams{
EndDate: hanzoai.F("end_date"),
StartDate: hanzoai.F("start_date"),
})
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())
}
}