mirror of
https://github.com/go-gitea/gitea.git
synced 2024-12-05 02:59:13 +01:00
2f8e1604f8
fix #27019 ## testfixture yml 1. add issue20(a pr issue) in repo 23, org 17 2. add user15 to team 9 3. add four reviews about issue20 ## test case add two tests that are described with code comments the code before pr #26784 failed the first test <img width="479" alt="image" src="https://github.com/go-gitea/gitea/assets/70063547/1d9b5787-11b4-4c4d-931f-6a9869547f35"> current code failed the second test(as mentioned in #27019) <img width="484" alt="image" src="https://github.com/go-gitea/gitea/assets/70063547/05608055-7587-43d1-bae1-92c688270819"> Any advice is appreciated. --------- Co-authored-by: CaiCandong <50507092+CaiCandong@users.noreply.github.com> Co-authored-by: Giteabot <teabot@gitea.io>
40 lines
1023 B
Go
40 lines
1023 B
Go
// Copyright 2021 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package integration
|
|
|
|
import (
|
|
"net/http"
|
|
"net/url"
|
|
"testing"
|
|
|
|
"code.gitea.io/gitea/modules/setting"
|
|
api "code.gitea.io/gitea/modules/structs"
|
|
"code.gitea.io/gitea/routers"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestNodeinfo(t *testing.T) {
|
|
setting.Federation.Enabled = true
|
|
testWebRoutes = routers.NormalRoutes()
|
|
defer func() {
|
|
setting.Federation.Enabled = false
|
|
testWebRoutes = routers.NormalRoutes()
|
|
}()
|
|
|
|
onGiteaRun(t, func(*testing.T, *url.URL) {
|
|
req := NewRequestf(t, "GET", "/api/v1/nodeinfo")
|
|
resp := MakeRequest(t, req, http.StatusOK)
|
|
VerifyJSONSchema(t, resp, "nodeinfo_2.1.json")
|
|
|
|
var nodeinfo api.NodeInfo
|
|
DecodeJSON(t, resp, &nodeinfo)
|
|
assert.True(t, nodeinfo.OpenRegistrations)
|
|
assert.Equal(t, "gitea", nodeinfo.Software.Name)
|
|
assert.Equal(t, 25, nodeinfo.Usage.Users.Total)
|
|
assert.Equal(t, 20, nodeinfo.Usage.LocalPosts)
|
|
assert.Equal(t, 2, nodeinfo.Usage.LocalComments)
|
|
})
|
|
}
|