forked from GoogleCloudPlatform/golang-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcaption_test.go
47 lines (36 loc) · 1.07 KB
/
caption_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
// Copyright 2016 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package main
import (
"bytes"
"strings"
"testing"
"github.com/GoogleCloudPlatform/golang-samples/internal/testutil"
)
func TestRecognize(t *testing.T) {
testutil.SystemTest(t)
var buf bytes.Buffer
if err := recognize(&buf, "../testdata/quit.raw"); err != nil {
t.Fatal(err)
}
if len(buf.String()) == 0 {
t.Fatal("got no results; want at least one")
}
if got, want := buf.String(), "quit"; !strings.Contains(got, want) {
t.Errorf("Transcript: got %q; want %q", got, want)
}
}
func TestRecognizeGCS(t *testing.T) {
testutil.SystemTest(t)
var buf bytes.Buffer
if err := recognizeGCS(&buf, "gs://python-docs-samples-tests/speech/audio.raw"); err != nil {
t.Fatal(err)
}
if len(buf.String()) == 0 {
t.Fatal("got no results; want at least one")
}
if got, want := buf.String(), "how old is the Brooklyn Bridge"; !strings.Contains(got, want) {
t.Errorf("Transcript: got %q; want %q", got, want)
}
}