File tree Expand file tree Collapse file tree 2 files changed +61
-0
lines changed Expand file tree Collapse file tree 2 files changed +61
-0
lines changed Original file line number Diff line number Diff line change
1
+ package voice
2
+
3
+ import (
4
+ "io/ioutil"
5
+ "net/http"
6
+ "testing"
7
+ )
8
+
9
+ func TestRecordingGetFile (t * testing.T ) {
10
+ fileContents := []byte ("this is not really a WAV file" )
11
+ mbClient , stop := testClient (http .StatusOK , []byte (fileContents ))
12
+ defer stop ()
13
+
14
+ rec := & Recording {
15
+ ID : "1337" ,
16
+ links : map [string ]string {
17
+ "file" : "/yolo/swag.wav" ,
18
+ },
19
+ }
20
+ r , err := rec .DownloadFile (mbClient )
21
+ if err != nil {
22
+ t .Fatal (err )
23
+ }
24
+ wav , err := ioutil .ReadAll (r )
25
+ if err != nil {
26
+ t .Fatal (err )
27
+ }
28
+ if string (wav ) != string (fileContents ) {
29
+ t .Logf ("exp: %q" , string (fileContents ))
30
+ t .Logf ("got: %q" , string (wav ))
31
+ t .Fatalf ("mismatched downloaded contents" )
32
+ }
33
+ }
Original file line number Diff line number Diff line change
1
+ package voice
2
+
3
+ import (
4
+ "net/http"
5
+ "testing"
6
+ )
7
+
8
+ func TestTranscriptionGetContents (t * testing.T ) {
9
+ text := "the quick brown fox jumps over the lazy dog"
10
+ mbClient , stop := testClient (http .StatusOK , []byte (text ))
11
+ defer stop ()
12
+
13
+ trans := & Transcription {
14
+ ID : "1337" ,
15
+ links : map [string ]string {
16
+ "file" : "/yolo/swag.txt" ,
17
+ },
18
+ }
19
+ contents , err := trans .Contents (mbClient )
20
+ if err != nil {
21
+ t .Fatal (err )
22
+ }
23
+ if contents != text {
24
+ t .Logf ("exp: %q" , text )
25
+ t .Logf ("got: %q" , contents )
26
+ t .Fatalf ("mismatched downloaded contents" )
27
+ }
28
+ }
You can’t perform that action at this time.
0 commit comments