forked from saintpete/twilio-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
transcription_test.go
44 lines (40 loc) · 1.06 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
package twilio
import (
"net/http"
"net/http/httptest"
"testing"
"time"
"golang.org/x/net/context"
)
func TestTranscriptionDelete(t *testing.T) {
t.Parallel()
called := false
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
called = true
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(204)
}))
defer s.Close()
client := NewClient("AC123", "123", nil)
client.Base = s.URL
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
err := client.Transcriptions.Delete(ctx, "TR4c7f9a71f19b7509cb1e8344af78fc82")
if err != nil {
t.Fatal(err)
}
if called == false {
t.Error("never hit server")
}
}
func TestTranscriptionDeleteTwice(t *testing.T) {
t.Parallel()
client, server := getServerCode(transcriptionDeletedTwice, 404)
defer server.Close()
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
err := client.Transcriptions.Delete(ctx, "TR4c7f9a71f19b7509cb1e8344af78fc82")
if err != nil {
t.Fatal(err)
}
}