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

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)
}
})
}
}