-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclient_test.go
More file actions
103 lines (97 loc) · 2.38 KB
/
Copy pathclient_test.go
File metadata and controls
103 lines (97 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package elevenlabs
import (
"os"
"testing"
)
func TestNewClient(t *testing.T) {
// Test creating client without API key (uses environment)
client, err := NewClient()
if err != nil {
t.Fatalf("NewClient() error = %v", err)
}
if client == nil {
t.Fatal("NewClient() returned nil client")
}
// Verify services are initialized
if client.TextToSpeech() == nil {
t.Error("TextToSpeech() service is nil")
}
if client.Voices() == nil {
t.Error("Voices() service is nil")
}
if client.Models() == nil {
t.Error("Models() service is nil")
}
if client.History() == nil {
t.Error("History() service is nil")
}
if client.User() == nil {
t.Error("User() service is nil")
}
if client.Dubbing() == nil {
t.Error("Dubbing() service is nil")
}
if client.SoundEffects() == nil {
t.Error("SoundEffects() service is nil")
}
if client.Pronunciation() == nil {
t.Error("Pronunciation() service is nil")
}
if client.Projects() == nil {
t.Error("Projects() service is nil")
}
if client.SpeechToText() == nil {
t.Error("SpeechToText() service is nil")
}
if client.ForcedAlignment() == nil {
t.Error("ForcedAlignment() service is nil")
}
if client.AudioIsolation() == nil {
t.Error("AudioIsolation() service is nil")
}
if client.TextToDialogue() == nil {
t.Error("TextToDialogue() service is nil")
}
if client.VoiceDesign() == nil {
t.Error("VoiceDesign() service is nil")
}
if client.Music() == nil {
t.Error("Music() service is nil")
}
if client.API() == nil {
t.Error("API() returned nil")
}
}
func TestNewClientWithAPIKey(t *testing.T) {
client, err := NewClient(WithAPIKey("test-api-key"))
if err != nil {
t.Fatalf("NewClient(WithAPIKey()) error = %v", err)
}
if client == nil {
t.Fatal("NewClient() returned nil client")
}
}
func TestNewClientWithOptions(t *testing.T) {
client, err := NewClient(
WithAPIKey("test-api-key"),
WithBaseURL("https://custom.api.com"),
)
if err != nil {
t.Fatalf("NewClient() error = %v", err)
}
if client == nil {
t.Fatal("NewClient() returned nil client")
}
if client.baseURL != "https://custom.api.com" {
t.Errorf("baseURL = %s, want https://custom.api.com", client.baseURL)
}
}
// Helper function to get API key for live tests
func getAPIKey(t *testing.T) string {
t.Helper()
apiKey := os.Getenv("ELEVENLABS_API_KEY")
if apiKey == "" {
t.Skip("ELEVENLABS_API_KEY not set, skipping live API test")
}
return apiKey
}