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.

api_nodeinfo_test.go 938B

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2021 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package integrations
  5. import (
  6. "net/http"
  7. "net/url"
  8. "testing"
  9. "code.gitea.io/gitea/modules/setting"
  10. api "code.gitea.io/gitea/modules/structs"
  11. "github.com/stretchr/testify/assert"
  12. )
  13. func TestNodeinfo(t *testing.T) {
  14. onGiteaRun(t, func(*testing.T, *url.URL) {
  15. setting.Federation.Enabled = true
  16. defer func() {
  17. setting.Federation.Enabled = false
  18. }()
  19. req := NewRequestf(t, "GET", "/api/v1/nodeinfo")
  20. resp := MakeRequest(t, req, http.StatusOK)
  21. var nodeinfo api.NodeInfo
  22. DecodeJSON(t, resp, &nodeinfo)
  23. assert.True(t, nodeinfo.OpenRegistrations)
  24. assert.Equal(t, "gitea", nodeinfo.Software.Name)
  25. assert.Equal(t, 23, nodeinfo.Usage.Users.Total)
  26. assert.Equal(t, 15, nodeinfo.Usage.LocalPosts)
  27. assert.Equal(t, 2, nodeinfo.Usage.LocalComments)
  28. })
  29. }