-
Notifications
You must be signed in to change notification settings - Fork 23
/
transcription_test.go
92 lines (81 loc) · 2.74 KB
/
transcription_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
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
package plivo
import (
"encoding/json"
"errors"
"testing"
)
// without queryParam passed
func TestTranscriptionService_GetRecordingTranscription(t *testing.T) {
expectResponse("getRecordingTranscription.json", 200)
if _, err := client.Transcription.GetRecordingTranscription(GetRecordingTranscriptionRequest{
TranscriptionID: "e12d05fe-6979-485c-83dc-9276114dba3b",
}); err != nil {
panic(err)
}
cl := client.httpClient
client.httpClient = nil
_, err := client.Transcription.GetRecordingTranscription(GetRecordingTranscriptionRequest{})
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
}
client.httpClient = cl
}
// with queryParam
func TestTranscriptionService_GetRecordingTranscriptionWithParam(t *testing.T) {
expectResponse("getRecordingTranscription.json", 200)
if _, err := client.Transcription.GetRecordingTranscription(GetRecordingTranscriptionRequest{
TranscriptionID: "e12d05fe-6979-485c-83dc-9276114dba3b",
TranscriptionType: "raw",
}); err != nil {
panic(err)
}
cl := client.httpClient
client.httpClient = nil
_, err := client.Transcription.GetRecordingTranscription(GetRecordingTranscriptionRequest{})
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
}
client.httpClient = cl
}
func TestTranscriptionService_CreateRecordingTranscription(t *testing.T) {
expectResponse("createRecordingTranscription.json", 200)
var response map[string]interface{}
if err := json.Unmarshal([]byte(expectedResponse), &response); err != nil {
t.Fatalf("failed to unmarshal expected response: %v", err)
}
if _, err := client.Transcription.CreateRecordingTranscription(RecordingTranscriptionRequest{
RecordingID: "e12d05fe-6979-485c-83dc-9276114dba3b",
}); err != nil {
panic(err)
}
cl := client.httpClient
client.httpClient = nil
_, err := client.Transcription.CreateRecordingTranscription(RecordingTranscriptionRequest{})
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
}
client.httpClient = cl
}
func TestTranscriptionService_DeleteRecordingTranscription(t *testing.T) {
expectResponse("deleteRecordingTranscription.json", 202)
var response map[string]interface{}
if err := json.Unmarshal([]byte(expectedResponse), &response); err != nil {
t.Fatalf("failed to unmarshal expected response: %v", err)
}
if _, err := client.Transcription.DeleteRecordingTranscription(DeleteRecordingTranscriptionRequest{
TranscriptionID: "e12d05fe-6979-485c-83dc-9276114dba3b",
}); err != nil {
panic(err)
}
cl := client.httpClient
client.httpClient = nil
_, err := client.Transcription.DeleteRecordingTranscription(DeleteRecordingTranscriptionRequest{})
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
}
client.httpClient = cl
}