Files
Atay-Makhzan/tests/integration/api_nodeinfo_test.go
T

36 lines
1016 B
Go
Raw Normal View History

2021-10-18 01:36:56 -04:00
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
2021-10-18 01:36:56 -04:00
2022-09-02 15:18:23 -04:00
package integration
2021-10-18 01:36:56 -04:00
import (
"net/http"
"testing"
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
2025-03-11 05:45:42 +08:00
"code.gitea.io/gitea/modules/test"
2022-06-20 01:48:17 +02:00
"code.gitea.io/gitea/routers"
2025-03-11 05:45:42 +08:00
"code.gitea.io/gitea/tests"
2021-10-18 01:36:56 -04:00
"github.com/stretchr/testify/assert"
)
func TestNodeinfo(t *testing.T) {
2025-03-11 05:45:42 +08:00
defer tests.PrepareTestEnv(t)()
defer test.MockVariableValue(&setting.Federation.Enabled, true)()
defer test.MockVariableValue(&testWebRoutes, routers.NormalRoutes())()
2021-10-18 01:36:56 -04:00
2025-03-11 05:45:42 +08:00
req := NewRequest(t, "GET", "/api/v1/nodeinfo")
resp := MakeRequest(t, req, http.StatusOK)
VerifyJSONSchema(t, resp, "nodeinfo_2.1.json")
2022-12-17 07:22:34 +01:00
2025-03-11 05:45:42 +08:00
var nodeinfo api.NodeInfo
DecodeJSON(t, resp, &nodeinfo)
assert.True(t, nodeinfo.OpenRegistrations)
assert.Equal(t, "gitea", nodeinfo.Software.Name)
assert.Equal(t, 29, nodeinfo.Usage.Users.Total)
assert.Equal(t, 22, nodeinfo.Usage.LocalPosts)
assert.Equal(t, 3, nodeinfo.Usage.LocalComments)
2021-10-18 01:36:56 -04:00
}