-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhistory_test.go
More file actions
71 lines (57 loc) · 1.56 KB
/
history_test.go
File metadata and controls
71 lines (57 loc) · 1.56 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
package elevenlabs
import (
"context"
"testing"
)
func TestHistoryList_Live(t *testing.T) {
apiKey := getAPIKey(t)
client, err := NewClient(WithAPIKey(apiKey))
if err != nil {
t.Fatalf("NewClient() error = %v", err)
}
resp, err := client.History().List(context.Background(), nil)
if err != nil {
t.Fatalf("History().List() error = %v", err)
}
if resp == nil {
t.Fatal("History().List() returned nil")
}
// Items can be empty if user has no history
t.Logf("History items: %d, HasMore: %v", len(resp.Items), resp.HasMore)
}
func TestHistoryListWithOptions_Live(t *testing.T) {
apiKey := getAPIKey(t)
client, err := NewClient(WithAPIKey(apiKey))
if err != nil {
t.Fatalf("NewClient() error = %v", err)
}
opts := &HistoryListOptions{
PageSize: 5,
}
resp, err := client.History().List(context.Background(), opts)
if err != nil {
t.Fatalf("History().List() error = %v", err)
}
if resp == nil {
t.Fatal("History().List() returned nil")
}
// Verify page size is respected (if there are items)
if len(resp.Items) > 5 {
t.Errorf("History().List() returned %d items, expected max 5", len(resp.Items))
}
}
func TestHistoryGetValidation(t *testing.T) {
client, _ := NewClient()
_, err := client.History().Get(context.Background(), "")
if err == nil {
t.Error("Get('') should return error")
}
_, err = client.History().GetAudio(context.Background(), "")
if err == nil {
t.Error("GetAudio('') should return error")
}
err = client.History().Delete(context.Background(), "")
if err == nil {
t.Error("Delete('') should return error")
}
}