Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds the Africa's Talking 'Expired' Status in Its Handler #387

Merged
merged 1 commit into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion handlers/africastalking/africastalking.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ var statusMapping = map[string]courier.MsgStatusValue{
"Buffered": courier.MsgSent,
"Rejected": courier.MsgFailed,
"Failed": courier.MsgFailed,
"Expired": courier.MsgFailed,
}

// receiveStatus is our HTTP handler function for status updates
Expand All @@ -105,7 +106,7 @@ func (h *handler) receiveStatus(ctx context.Context, channel courier.Channel, w
msgStatus, found := statusMapping[form.Status]
if !found {
return nil, handlers.WriteAndLogRequestError(ctx, h, channel, w, r,
fmt.Errorf("unknown status '%s', must be one of 'Success','Sent','Buffered','Rejected' or 'Failed'", form.Status))
fmt.Errorf("unknown status '%s', must be one of 'Success','Sent','Buffered','Rejected', 'Failed', or 'Expired'", form.Status))
}

// write our status
Expand Down
6 changes: 4 additions & 2 deletions handlers/africastalking/africastalking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ var (

missingStatus = "id=ATXid_dda018a640edfcc5d2ce455de3e4a6e7"
invalidStatus = "id=ATXid_dda018a640edfcc5d2ce455de3e4a6e7&status=Borked"
validStatus = "id=ATXid_dda018a640edfcc5d2ce455de3e4a6e7&status=Success"
successStatus = "id=ATXid_dda018a640edfcc5d2ce455de3e4a6e7&status=Success"
expiredStatus = "id=ATXid_dda018a640edfcc5d2ce455de3e4a6e7&status=Expired"
)

var testCases = []ChannelHandleTestCase{
Expand All @@ -42,7 +43,8 @@ var testCases = []ChannelHandleTestCase{
{Label: "Invalid Date", URL: receiveURL, Data: invalidDate, Status: 400, Response: "invalid date format"},
{Label: "Status Invalid", URL: statusURL, Status: 400, Data: invalidStatus, Response: "unknown status"},
{Label: "Status Missing", URL: statusURL, Status: 400, Data: missingStatus, Response: "field 'status' required"},
{Label: "Status Valid", URL: statusURL, Status: 200, Data: validStatus, Response: `"status":"D"`},
{Label: "Status Success", URL: statusURL, Status: 200, Data: successStatus, Response: `"status":"D"`},
{Label: "Status Expired", URL: statusURL, Status: 200, Data: expiredStatus, Response: `"status":"F"`},
}

func TestHandler(t *testing.T) {
Expand Down