owl-blogs/cmd/owl/web/rss_test.go

32 lines
919 B
Go
Raw Normal View History

2022-09-05 18:34:24 +00:00
package web_test
2022-08-16 18:36:05 +00:00
import (
"h4kor/owl-blogs"
2022-09-05 18:34:24 +00:00
main "h4kor/owl-blogs/cmd/owl/web"
2022-11-06 13:17:14 +00:00
"h4kor/owl-blogs/test/assertions"
2022-08-16 18:36:05 +00:00
"net/http"
"net/http/httptest"
"testing"
)
func TestMultiUserUserRssIndexHandler(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
2022-08-16 18:36:05 +00:00
user, _ := repo.CreateUser("test-1")
2022-12-05 19:47:52 +00:00
user.CreateNewPost(owl.PostMeta{Type: "article", Title: "post-1"}, "")
2022-08-16 18:36:05 +00:00
// Create Request and Response
req, err := http.NewRequest("GET", user.UrlPath()+"index.xml", nil)
assertions.AssertNoError(t, err, "Error creating request")
2022-08-16 18:36:05 +00:00
rr := httptest.NewRecorder()
router := main.Router(&repo)
router.ServeHTTP(rr, req)
assertions.AssertStatus(t, rr, http.StatusOK)
2022-08-16 18:36:05 +00:00
// Check the response Content-Type is what we expect.
assertions.AssertContains(t, rr.Header().Get("Content-Type"), "application/rss+xml")
2022-08-16 18:36:05 +00:00
// Check the response body contains names of users
assertions.AssertContains(t, rr.Body.String(), "post-1")
2022-08-16 18:36:05 +00:00
}