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]>
96 lines
2.5 KiB
Go
96 lines
2.5 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 TestGlobalSpendListTagsWithOptionalParams(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.Global.Spend.ListTags(context.TODO(), hanzoai.GlobalSpendListTagsParams{
|
|
EndDate: hanzoai.F("end_date"),
|
|
StartDate: hanzoai.F("start_date"),
|
|
Tags: hanzoai.F("tags"),
|
|
})
|
|
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 TestGlobalSpendReset(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.Global.Spend.Reset(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 TestGlobalSpendGetReportWithOptionalParams(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.Global.Spend.GetReport(context.TODO(), hanzoai.GlobalSpendGetReportParams{
|
|
APIKey: hanzoai.F("api_key"),
|
|
CustomerID: hanzoai.F("customer_id"),
|
|
EndDate: hanzoai.F("end_date"),
|
|
GroupBy: hanzoai.F(hanzoai.GlobalSpendGetReportParamsGroupByTeam),
|
|
InternalUserID: hanzoai.F("internal_user_id"),
|
|
StartDate: hanzoai.F("start_date"),
|
|
TeamID: hanzoai.F("team_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())
|
|
}
|
|
}
|