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]>
89 lines
2.3 KiB
Go
89 lines
2.3 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 TestCredentialNewWithOptionalParams(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.Credentials.New(context.TODO(), hanzoai.CredentialNewParams{
|
|
CredentialInfo: hanzoai.F[any](map[string]interface{}{}),
|
|
CredentialName: hanzoai.F("credential_name"),
|
|
CredentialValues: hanzoai.F[any](map[string]interface{}{}),
|
|
ModelID: hanzoai.F("model_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 TestCredentialList(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.Credentials.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 TestCredentialDelete(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.Credentials.Delete(context.TODO(), "credential_name")
|
|
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())
|
|
}
|
|
}
|