forked from saintpete/twilio-go
-
Notifications
You must be signed in to change notification settings - Fork 69
/
fax_test.go
62 lines (58 loc) · 1.47 KB
/
fax_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
package twilio
import (
"context"
"net/url"
"testing"
)
func TestGetFax(t *testing.T) {
t.Parallel()
client, server := getServer(faxGetResponse)
defer server.Close()
fax, err := client.Fax.Faxes.Get(context.Background(), "FXeb76f282888a074547beba3516552174")
if err != nil {
t.Fatal(err)
}
if fax.Quality != "fine" {
t.Errorf("quality is incorrect")
}
if fax.FriendlyPrice() != "$0.014" {
t.Errorf("FriendlyPrice(): got %s, want $0.014", fax.FriendlyPrice())
}
if fax.NumPages != 1 {
t.Errorf("wrong NumPages %d", fax.NumPages)
}
if fax.Status != StatusDelivered {
t.Errorf("wrong status: %s", fax.Status)
}
}
func TestGetFaxPage(t *testing.T) {
t.Parallel()
client, server := getServer(faxGetPageResponse)
defer server.Close()
page, err := client.Fax.Faxes.GetPage(context.Background(), nil)
if err != nil {
t.Fatal(err)
}
if len(page.Faxes) == 0 {
t.Errorf("too few faxes returned")
}
}
func TestSendFax(t *testing.T) {
t.Parallel()
client, server := getServer(faxCreateResponse)
defer server.Close()
data := url.Values{
"To": []string{"+18326327228"},
"From": []string{"+19252717005"},
"MediaUrl": []string{"https://kb.ngrok.io/gopher.pdf"},
"Quality": []string{"fine"},
"StatusCallback": []string{"https://kb.ngrok.io/fax-callback"},
}
fax, err := client.Fax.Faxes.Create(context.Background(), data)
if err != nil {
t.Fatal(err)
}
if fax.Quality != "fine" {
t.Errorf("quality is incorrect")
}
}