1
1
package voice
2
2
3
3
import (
4
+ "fmt"
4
5
"net/http"
5
6
"testing"
7
+
8
+ "github.com/messagebird/go-rest-api/internal/mbtest"
6
9
)
7
10
11
+ func TestMain (m * testing.M ) {
12
+ mbtest .EnableServer (m )
13
+ }
14
+
8
15
func TestTranscriptionGetContents (t * testing.T ) {
9
16
text := "the quick brown fox jumps over the lazy dog"
10
17
mbClient , stop := testRequest (http .StatusOK , []byte (text ))
@@ -28,23 +35,14 @@ func TestTranscriptionGetContents(t *testing.T) {
28
35
}
29
36
30
37
func TestCreateTranscription (t * testing.T ) {
31
- mbClient , stop := testRequest (http .StatusOK , []byte (`{
32
- "data": [
33
- {
34
- "id": "00000000-1111-2222-3333-444444444444",
35
- "recordingId": "55555555-6666-7777-8888-999999999999",
36
- "error": null,
37
- "createdAt": "2011-01-01T02:03:04Z",
38
- "updatedAt": "2011-01-02T03:04:05Z"
39
- }
40
- ]
41
- }` ))
42
- defer stop ()
38
+ mbtest .WillReturnTestdata (t , "transcriptObject.json" , http .StatusOK )
39
+ client := mbtest .Client (t )
43
40
44
41
callID , legID , recordingID := "7777777" , "88888888" , "999999999"
45
-
46
- _ , err := CreateTranscription (mbClient , callID , legID , recordingID )
42
+ _ , err := CreateTranscription (client , callID , legID , recordingID )
47
43
if err != nil {
48
44
t .Fatal (err )
49
45
}
46
+
47
+ mbtest .AssertEndpointCalled (t , http .MethodPost , fmt .Sprintf ("/calls/%s/legs/%s/recordings/%s/transcriptions" , callID , legID , recordingID ))
50
48
}
0 commit comments