Skip to content

Commit

Permalink
fix twilio path
Browse files Browse the repository at this point in the history
  • Loading branch information
nicpottier committed Sep 10, 2017
1 parent 6323431 commit da653e8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions handlers/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type ChannelSendTestCase struct {
ResponseStatus int
ResponseBody string

Path string
URLParams map[string]string
PostParams map[string]string
RequestBody string
Expand Down Expand Up @@ -184,6 +185,11 @@ func RunChannelSendTestCases(t *testing.T, channel courier.Channel, handler cour
t.Errorf("unexpected error: %s", err.Error())
}

if testCase.Path != "" {
require.NotNil(testRequest)
require.Equal(testCase.Path, testRequest.URL.Path)
}

if testCase.URLParams != nil {
require.NotNil(testRequest)
for k, v := range testCase.URLParams {
Expand Down
3 changes: 2 additions & 1 deletion handlers/twilio/twilio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func BenchmarkHandler(b *testing.B) {

// setSendURL takes care of setting the send_url to our test server host
func setSendURL(server *httptest.Server, channel courier.Channel, msg courier.Msg) {
sendURL = server.URL
sendURL = server.URL + "/Account/"
}

var defaultSendTestCases = []ChannelSendTestCase{
Expand All @@ -79,6 +79,7 @@ var defaultSendTestCases = []ChannelSendTestCase{
Status: "W", ExternalID: "1002",
ResponseBody: `{ "sid": "1002" }`, ResponseStatus: 200,
PostParams: map[string]string{"Body": "Simple Message ☺", "To": "+250788383383"},
Path: "/Account/accountSID/Messages.json",
SendPrep: setSendURL},
{Label: "Error Sending",
Text: "Error Message", URN: "tel:+250788383383",
Expand Down
4 changes: 3 additions & 1 deletion utils/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ func AddURLPath(urlStr string, paths ...string) (string, error) {
if err != nil {
return "", err
}
p, err := url.Parse(path.Join(paths...))
allPaths := []string{u.Path}
allPaths = append(allPaths, paths...)
p, err := url.Parse(path.Join(allPaths...))
if err != nil {
return "", err
}
Expand Down

0 comments on commit da653e8

Please sign in to comment.