forked from subosito/twilio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelper_test.go
49 lines (40 loc) · 841 Bytes
/
helper_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
package twilio
import (
"encoding/base64"
"net/http"
"net/http/httptest"
"net/url"
"testing"
"time"
)
const (
accountSid = "AC5ef87"
authToken = "2ecaf01"
)
var (
mux *http.ServeMux
client *Client
server *httptest.Server
)
func setup() {
mux = http.NewServeMux()
server = httptest.NewServer(mux)
client = NewClient(accountSid, authToken, nil)
client.BaseURL, _ = url.Parse(server.URL)
}
func teardown() {
server.Close()
}
func encodeAuth() string {
s := accountSid + ":" + authToken
return ("Basic " + base64.StdEncoding.EncodeToString([]byte(s)))
}
func parseTimestamp(s string) Timestamp {
tm, _ := time.Parse(time.RFC1123Z, s)
return Timestamp{Time: tm}
}
func testMethod(t *testing.T, r *http.Request, want string) {
if want != r.Method {
t.Errorf("Request method = %v, want %v", r.Method, want)
}
}