2022-09-05 18:34:24 +00:00
|
|
|
package web_test
|
2022-08-16 18:36:05 +00:00
|
|
|
|
|
|
|
import (
|
2022-09-05 18:50:46 +00:00
|
|
|
"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) {
|
2022-09-05 18:50:46 +00:00
|
|
|
repo := getTestRepo(owl.RepoConfig{})
|
2022-08-16 18:36:05 +00:00
|
|
|
user, _ := repo.CreateUser("test-1")
|
2022-10-13 18:33:00 +00:00
|
|
|
user.CreateNewPost("post-1", false)
|
2022-08-16 18:36:05 +00:00
|
|
|
|
|
|
|
// Create Request and Response
|
|
|
|
req, err := http.NewRequest("GET", user.UrlPath()+"index.xml", nil)
|
2022-11-02 21:02:49 +00:00
|
|
|
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)
|
|
|
|
|
2022-11-02 21:02:49 +00:00
|
|
|
assertions.AssertStatus(t, rr, http.StatusOK)
|
2022-08-16 18:36:05 +00:00
|
|
|
|
|
|
|
// Check the response Content-Type is what we expect.
|
2022-11-02 21:02:49 +00:00
|
|
|
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
|
2022-11-02 21:02:49 +00:00
|
|
|
assertions.AssertContains(t, rr.Body.String(), "post-1")
|
2022-08-16 18:36:05 +00:00
|
|
|
}
|