Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

api_nodeinfo_test.go 1022B

1234567891011121314151617181920212223242526272829303132333435363738
  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. "code.gitea.io/gitea/routers"
  12. "github.com/stretchr/testify/assert"
  13. )
  14. func TestNodeinfo(t *testing.T) {
  15. setting.Federation.Enabled = true
  16. c = routers.NormalRoutes()
  17. defer func() {
  18. setting.Federation.Enabled = false
  19. c = routers.NormalRoutes()
  20. }()
  21. onGiteaRun(t, func(*testing.T, *url.URL) {
  22. req := NewRequestf(t, "GET", "/api/v1/nodeinfo")
  23. resp := MakeRequest(t, req, http.StatusOK)
  24. var nodeinfo api.NodeInfo
  25. DecodeJSON(t, resp, &nodeinfo)
  26. assert.True(t, nodeinfo.OpenRegistrations)
  27. assert.Equal(t, "gitea", nodeinfo.Software.Name)
  28. assert.Equal(t, 23, nodeinfo.Usage.Users.Total)
  29. assert.Equal(t, 17, nodeinfo.Usage.LocalPosts)
  30. assert.Equal(t, 2, nodeinfo.Usage.LocalComments)
  31. })
  32. }