You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.0 KiB
40 lines
1.0 KiB
3 years ago
|
// Copyright 2021 The Gitea Authors. All rights reserved.
|
||
|
// Use of this source code is governed by a MIT-style
|
||
|
// license that can be found in the LICENSE file.
|
||
|
|
||
2 years ago
|
package integration
|
||
3 years ago
|
|
||
|
import (
|
||
2 years ago
|
"context"
|
||
3 years ago
|
"net/http"
|
||
|
"net/url"
|
||
|
"testing"
|
||
|
|
||
|
"code.gitea.io/gitea/modules/setting"
|
||
|
api "code.gitea.io/gitea/modules/structs"
|
||
3 years ago
|
"code.gitea.io/gitea/routers"
|
||
3 years ago
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestNodeinfo(t *testing.T) {
|
||
3 years ago
|
setting.Federation.Enabled = true
|
||
2 years ago
|
c = routers.NormalRoutes(context.TODO())
|
||
3 years ago
|
defer func() {
|
||
|
setting.Federation.Enabled = false
|
||
2 years ago
|
c = routers.NormalRoutes(context.TODO())
|
||
3 years ago
|
}()
|
||
3 years ago
|
|
||
3 years ago
|
onGiteaRun(t, func(*testing.T, *url.URL) {
|
||
3 years ago
|
req := NewRequestf(t, "GET", "/api/v1/nodeinfo")
|
||
|
resp := MakeRequest(t, req, http.StatusOK)
|
||
|
var nodeinfo api.NodeInfo
|
||
|
DecodeJSON(t, resp, &nodeinfo)
|
||
3 years ago
|
assert.True(t, nodeinfo.OpenRegistrations)
|
||
3 years ago
|
assert.Equal(t, "gitea", nodeinfo.Software.Name)
|
||
3 years ago
|
assert.Equal(t, 23, nodeinfo.Usage.Users.Total)
|
||
3 years ago
|
assert.Equal(t, 17, nodeinfo.Usage.LocalPosts)
|
||
3 years ago
|
assert.Equal(t, 2, nodeinfo.Usage.LocalComments)
|
||
3 years ago
|
})
|
||
|
}
|