Skip to content

Commit

Permalink
Fix webhook api tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklaw5 committed Aug 24, 2018
1 parent 407c780 commit a842e5f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions webhooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"
)

func GetWebhookSubscriptions(t *testing.T) {
func TestGetWebhookSubscriptions(t *testing.T) {
t.Parallel()

testCases := []struct {
Expand All @@ -15,7 +15,7 @@ func GetWebhookSubscriptions(t *testing.T) {
respBody string
}{
{
http.StatusBadRequest,
http.StatusUnauthorized,
&Options{ClientID: "my-client-id"},
2,
`{"error":"Unauthorized","status":401,"message":"Must provide valid app token."}`,
Expand All @@ -42,16 +42,16 @@ func GetWebhookSubscriptions(t *testing.T) {
t.Errorf("expected status code to be \"%d\", got \"%d\"", testCase.statusCode, resp.StatusCode)
}

if resp.StatusCode == http.StatusBadRequest {
if resp.Error != "Bad Request" {
if resp.StatusCode == http.StatusUnauthorized {
if resp.Error != "Unauthorized" {
t.Errorf("expected error to be \"%s\", got \"%s\"", "Bad Request", resp.Error)
}

if resp.ErrorStatus != http.StatusBadRequest {
t.Errorf("expected error status to be \"%d\", got \"%d\"", http.StatusBadRequest, resp.ErrorStatus)
if resp.ErrorStatus != http.StatusUnauthorized {
t.Errorf("expected error status to be \"%d\", got \"%d\"", http.StatusUnauthorized, resp.ErrorStatus)
}

expectedErrMsg := "Must provide either from_id or to_id"
expectedErrMsg := "Must provide valid app token."
if resp.ErrorMessage != expectedErrMsg {
t.Errorf("expected error message to be \"%s\", got \"%s\"", expectedErrMsg, resp.ErrorMessage)
}
Expand Down

0 comments on commit a842e5f

Please sign in to comment.