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]>
100 lines
2.2 KiB
Go
100 lines
2.2 KiB
Go
package hanzoai
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hanzoai/go-sdk/option"
|
|
)
|
|
|
|
func TestNewModelService(t *testing.T) {
|
|
service := NewModelService()
|
|
if service == nil {
|
|
t.Fatal("NewModelService() returned nil")
|
|
}
|
|
if service.Info == nil {
|
|
t.Error("ModelService.Info is nil")
|
|
}
|
|
if service.Update == nil {
|
|
t.Error("ModelService.Update is nil")
|
|
}
|
|
}
|
|
|
|
func TestNewModelServiceWithOptions(t *testing.T) {
|
|
opts := []option.RequestOption{
|
|
option.WithAPIKey("test-key"),
|
|
}
|
|
service := NewModelService(opts...)
|
|
if service == nil {
|
|
t.Fatal("NewModelService() returned nil")
|
|
}
|
|
if len(service.Options) != len(opts) {
|
|
t.Errorf("ModelService.Options length = %d, want %d", len(service.Options), len(opts))
|
|
}
|
|
}
|
|
|
|
func TestNewDeleteService(t *testing.T) {
|
|
service := NewDeleteService()
|
|
if service == nil {
|
|
t.Fatal("NewDeleteService() returned nil")
|
|
}
|
|
}
|
|
|
|
func TestNewDeleteServiceWithOptions(t *testing.T) {
|
|
opts := []option.RequestOption{
|
|
option.WithAPIKey("test-key"),
|
|
}
|
|
service := NewDeleteService(opts...)
|
|
if service == nil {
|
|
t.Fatal("NewDeleteService() returned nil")
|
|
}
|
|
if len(service.Options) != len(opts) {
|
|
t.Errorf("DeleteService.Options length = %d, want %d", len(service.Options), len(opts))
|
|
}
|
|
}
|
|
|
|
func TestNewModelInfoService(t *testing.T) {
|
|
service := NewModelInfoService()
|
|
if service == nil {
|
|
t.Fatal("NewModelInfoService() returned nil")
|
|
}
|
|
}
|
|
|
|
func TestNewModelUpdateService(t *testing.T) {
|
|
service := NewModelUpdateService()
|
|
if service == nil {
|
|
t.Fatal("NewModelUpdateService() returned nil")
|
|
}
|
|
}
|
|
|
|
func TestModelInfoParam_MarshalJSON(t *testing.T) {
|
|
param := ModelInfoParam{
|
|
ID: F("test-id"),
|
|
}
|
|
|
|
data, err := param.MarshalJSON()
|
|
if err != nil {
|
|
t.Fatalf("MarshalJSON() error = %v", err)
|
|
}
|
|
if data == nil {
|
|
t.Error("MarshalJSON() returned nil data")
|
|
}
|
|
}
|
|
|
|
func TestModelInfoTier_IsKnown(t *testing.T) {
|
|
tests := []struct {
|
|
tier ModelInfoTier
|
|
isKnown bool
|
|
}{
|
|
{ModelInfoTierFree, true},
|
|
{ModelInfoTierPaid, true},
|
|
{ModelInfoTier("unknown"), false},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(string(tt.tier), func(t *testing.T) {
|
|
if got := tt.tier.IsKnown(); got != tt.isKnown {
|
|
t.Errorf("IsKnown() = %v, want %v", got, tt.isKnown)
|
|
}
|
|
})
|
|
}
|
|
} |