// Copyright 2025 The Forgejo Authors. All rights reserved. // SPDX-License-Identifier: GPL-3.0-or-later package integration import ( "net/http" "regexp" "testing" "code.gitea.io/gitea/tests" "github.com/stretchr/testify/assert" ) func TestReleaseFeed(t *testing.T) { defer tests.PrepareTestEnv(t)() normalize := func(body string) string { // Remove port. body = regexp.MustCompile(`localhost:\d+`).ReplaceAllString(body, "localhost") // date is timezone dependent. body = regexp.MustCompile(`.*`).ReplaceAllString(body, "") body = regexp.MustCompile(`.*`).ReplaceAllString(body, "") return body } t.Run("RSS feed", func(t *testing.T) { defer tests.PrintCurrentTest(t)() resp := MakeRequest(t, NewRequest(t, "GET", "/user2/repo1/releases.rss"), http.StatusOK) assert.EqualValues(t, ` Releases for user2/repo1 http://localhost/user2/repo1/release pre-release http://localhost/user2/repo1/releases/tag/v1.0 some text for a pre release

]]>
user2 5: http://localhost/user2/repo1/releases/tag/v1.0
testing-release http://localhost/user2/repo1/releases/tag/v1.1 user2 1: http://localhost/user2/repo1/releases/tag/v1.1
`, normalize(resp.Body.String())) }) t.Run("Atom feed", func(t *testing.T) { defer tests.PrintCurrentTest(t)() resp := MakeRequest(t, NewRequest(t, "GET", "/user2/repo1/releases.atom"), http.StatusOK) assert.EqualValues(t, ` Releases for user2/repo1 http://localhost/user2/repo1/release pre-release 5: http://localhost/user2/repo1/releases/tag/v1.0 <p dir="auto">some text for a pre release</p> user2 user2@noreply.example.org testing-release 1: http://localhost/user2/repo1/releases/tag/v1.1 user2 user2@noreply.example.org `, normalize(resp.Body.String())) }) }