File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ package voice
2
+
3
+ import (
4
+ "crypto/tls"
5
+ "log"
6
+ "net"
7
+ "net/http"
8
+ "net/http/httptest"
9
+ "os"
10
+ "testing"
11
+
12
+ "github.com/messagebird/go-rest-api"
13
+ )
14
+
15
+ func testClient (status int , body []byte ) (* messagebird.Client , func ()) {
16
+ mbServer := httptest .NewTLSServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
17
+ w .Header ().Set ("Content-Type" , "application/json" )
18
+ w .WriteHeader (status )
19
+ w .Write (body )
20
+ }))
21
+ addr := mbServer .Listener .Addr ().String ()
22
+ transport := & http.Transport {
23
+ DialTLS : func (netw , _ string ) (net.Conn , error ) {
24
+ return tls .Dial (netw , addr , & tls.Config {InsecureSkipVerify : true })
25
+ },
26
+ }
27
+ mbClient := & messagebird.Client {
28
+ AccessKey : "test_gshuPaZoeEG6ovbc8M79w0QyM" ,
29
+ HTTPClient : & http.Client {Transport : transport },
30
+ }
31
+ if testing .Verbose () {
32
+ mbClient .DebugLog = log .New (os .Stdout , "DEBUG" , log .Lshortfile )
33
+ }
34
+ return mbClient , func () { mbServer .Close () }
35
+ }
You can’t perform that action at this time.
0 commit comments