-
Notifications
You must be signed in to change notification settings - Fork 6
/
ivona_test.go
63 lines (49 loc) · 1.39 KB
/
ivona_test.go
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
package ivona_test
import (
"os"
"testing"
ivona "github.com/jpadilla/ivona-go"
)
var (
ivonaAccessKey = os.Getenv("IVONA_ACCESS_KEY")
ivonaSecretKey = os.Getenv("IVONA_SECRET_KEY")
testText = "Hello World"
)
func init() {
if len(ivonaAccessKey) == 0 || len(ivonaSecretKey) == 0 {
panic("IVONA_ACCESS_KEY and IVONA_SECRET_KEY environment variables are needed to run tests!\n")
}
}
func TestIvona_CreateSpeech(t *testing.T) {
client := ivona.New(ivonaAccessKey, ivonaSecretKey)
options := ivona.NewSpeechOptions(testText)
r, err := client.CreateSpeech(options)
if err != nil {
t.Error(err)
}
audioLength := len(r.Audio)
expectedAudioLength := 6314
expectedContentType := "audio/mpeg"
if r.ContentType != expectedContentType {
t.Errorf("ContentType %v does not match", r.ContentType)
}
if audioLength != expectedAudioLength {
t.Errorf("Audio length %v does not match", audioLength)
}
}
func TestIvona_ListVoices(t *testing.T) {
client := ivona.New(ivonaAccessKey, ivonaSecretKey)
r, err := client.ListVoices(ivona.Voice{})
if err != nil {
t.Error(err)
}
voicesLength := len(r.Voices)
expectedVoicesLength := 51
expectedContentType := "application/json"
if voicesLength != expectedVoicesLength {
t.Errorf("Voices length %v does not match", len(r.Voices))
}
if r.ContentType != expectedContentType {
t.Errorf("ContentType %v does not match", r.ContentType)
}
}