Skip to content

Commit

Permalink
Add tests for all expected subscription attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
mbklein committed Oct 14, 2019
1 parent 0a962b1 commit cbd47e4
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app/gosns/gosns_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package gosns

import (
"github.com/gorilla/mux"
"net/http"
"net/http/httptest"
"net/url"
"strings"
"testing"
"time"

"github.com/gorilla/mux"

"github.com/p4tin/goaws/app"
"github.com/p4tin/goaws/app/common"
)
Expand Down Expand Up @@ -470,6 +471,17 @@ func TestGetSubscriptionAttributesHandler_POST_Success(t *testing.T) {
t.Errorf("handler returned unexpected body: got %v want %v",
rr.Body.String(), expected)
}

expectedElements := []string{"Owner", "RawMessageDelivery", "TopicArn", "Endpoint", "PendingConfirmation",
"ConfirmationWasAuthenticated", "SubscriptionArn", "Protocol", "FilterPolicy"}
for _, element := range expectedElements {
expected := "<key>" + element + "</key>"
if !strings.Contains(rr.Body.String(), expected) {
t.Errorf("handler returned unexpected body: got %v want %v",
rr.Body.String(), expected)
}
}

// Check the response body is what we expect.
expected = "{&#34;foo&#34;:[&#34;bar&#34;]}"
if !strings.Contains(rr.Body.String(), expected) {
Expand Down

0 comments on commit cbd47e4

Please sign in to comment.