diff --git a/src/github.com/matrix-org/go-neb/services/rssbot/rssbot_test.go b/src/github.com/matrix-org/go-neb/services/rssbot/rssbot_test.go index d75d096..0e64751 100644 --- a/src/github.com/matrix-org/go-neb/services/rssbot/rssbot_test.go +++ b/src/github.com/matrix-org/go-neb/services/rssbot/rssbot_test.go @@ -17,6 +17,25 @@ import ( "time" ) +const rssFeedXML = ` + + + + Mask Shop + + New Item: Majora’s Mask + http://go.neb/rss/majoras-mask + + +` + type MockTransport struct { roundTrip func(*http.Request) (*http.Response, error) } @@ -45,25 +64,7 @@ func TestHTMLEntities(t *testing.T) { } return &http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(bytes.NewBufferString(` - - - - - Mask Shop - - New Item: Majora’s Mask - http://go.neb/rss/majoras-mask - - - `)), + Body: ioutil.NopCloser(bytes.NewBufferString(rssFeedXML)), }, nil } cachingClient = &http.Client{Transport: rssTrans} @@ -76,9 +77,11 @@ func TestHTMLEntities(t *testing.T) { t.Fatal("Failed to create RSS bot: ", err) } rssbot := srv.(*rssBotService) + + // Configure the service to force OnPoll to query the RSS feed and attempt to send results + // to the right room. f := rssbot.Feeds[feedURL] f.Rooms = []string{"!linksroom:hyrule"} - f.FeedUpdatedTimestampSecs = 12345 f.NextPollTimestampSecs = time.Now().Unix() rssbot.Feeds[feedURL] = f @@ -94,7 +97,7 @@ func TestHTMLEntities(t *testing.T) { t.Fatal("Failed to decode request JSON: ", err) return nil, errors.New("Error handling matrix client test request") } - want := "New Item: Majora’s Mask" + want := "New Item: Majora\u2019s Mask" // 0x2019 = 8217 if !strings.Contains(msg.Body, want) { t.Errorf("TestHTMLEntities: want '%s' in body, got '%s'", want, msg.Body) }