mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-25 11:22:16 +00:00
[gitea] week 2025-06 cherry pick (gitea/main -> forgejo) (#6763)
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6763 Reviewed-by: Gusted <gusted@noreply.codeberg.org>
This commit is contained in:
commit
273bc9eb04
14 changed files with 277 additions and 9 deletions
|
@ -99,6 +99,29 @@ func TestAPIOrgCreate(t *testing.T) {
|
|||
assert.EqualValues(t, "user1", users[0].UserName)
|
||||
}
|
||||
|
||||
func TestAPIOrgRename(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
token := getUserToken(t, "user1", auth_model.AccessTokenScopeWriteOrganization)
|
||||
|
||||
org := api.CreateOrgOption{
|
||||
UserName: "user1_org",
|
||||
FullName: "User1's organization",
|
||||
Description: "This organization created by user1",
|
||||
Website: "https://try.gitea.io",
|
||||
Location: "Shanghai",
|
||||
Visibility: "limited",
|
||||
}
|
||||
req := NewRequestWithJSON(t, "POST", "/api/v1/orgs", &org).
|
||||
AddTokenAuth(token)
|
||||
MakeRequest(t, req, http.StatusCreated)
|
||||
|
||||
req = NewRequestWithJSON(t, "POST", "/api/v1/orgs/user1_org/rename", &api.RenameOrgOption{
|
||||
NewName: "renamed_org",
|
||||
}).AddTokenAuth(token)
|
||||
MakeRequest(t, req, http.StatusNoContent)
|
||||
unittest.AssertExistsAndLoadBean(t, &org_model.Organization{Name: "renamed_org"})
|
||||
}
|
||||
|
||||
func TestAPIOrgEdit(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
session := loginUser(t, "user1")
|
||||
|
|
36
tests/integration/feed_repo_test.go
Normal file
36
tests/integration/feed_repo_test.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/tests"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestFeedRepo(t *testing.T) {
|
||||
t.Run("RSS", func(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo1.rss")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
data := resp.Body.String()
|
||||
assert.Contains(t, data, `<rss version="2.0"`)
|
||||
|
||||
var rss RSS
|
||||
err := xml.Unmarshal(resp.Body.Bytes(), &rss)
|
||||
require.NoError(t, err)
|
||||
assert.Contains(t, rss.Channel.Link, "/user2/repo1")
|
||||
assert.NotEmpty(t, rss.Channel.PubDate)
|
||||
assert.Len(t, rss.Channel.Items, 1)
|
||||
assert.EqualValues(t, "issue5", rss.Channel.Items[0].Description)
|
||||
assert.NotEmpty(t, rss.Channel.Items[0].PubDate)
|
||||
})
|
||||
}
|
|
@ -4,6 +4,7 @@
|
|||
package integration
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
|
@ -15,6 +16,22 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// RSS is a struct to unmarshal RSS feeds test only
|
||||
type RSS struct {
|
||||
Channel struct {
|
||||
Title string `xml:"title"`
|
||||
Link string `xml:"link"`
|
||||
Description string `xml:"description"`
|
||||
PubDate string `xml:"pubDate"`
|
||||
Items []struct {
|
||||
Title string `xml:"title"`
|
||||
Link string `xml:"link"`
|
||||
Description string `xml:"description"`
|
||||
PubDate string `xml:"pubDate"`
|
||||
} `xml:"item"`
|
||||
} `xml:"channel"`
|
||||
}
|
||||
|
||||
func TestFeed(t *testing.T) {
|
||||
defer tests.AddFixtures("tests/integration/fixtures/TestFeed/")()
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
@ -38,6 +55,12 @@ func TestFeed(t *testing.T) {
|
|||
|
||||
data := resp.Body.String()
|
||||
assert.Contains(t, data, `<rss version="2.0"`)
|
||||
|
||||
var rss RSS
|
||||
err := xml.Unmarshal(resp.Body.Bytes(), &rss)
|
||||
require.NoError(t, err)
|
||||
assert.Contains(t, rss.Channel.Link, "/user2")
|
||||
assert.NotEmpty(t, rss.Channel.PubDate)
|
||||
})
|
||||
})
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue