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.

routes_test.go 932B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright 2023 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package install
  4. import (
  5. "net/http/httptest"
  6. "path/filepath"
  7. "testing"
  8. "code.gitea.io/gitea/models/unittest"
  9. "github.com/stretchr/testify/assert"
  10. )
  11. func TestRoutes(t *testing.T) {
  12. r := Routes()
  13. assert.NotNil(t, r)
  14. w := httptest.NewRecorder()
  15. req := httptest.NewRequest("GET", "/", nil)
  16. r.ServeHTTP(w, req)
  17. assert.EqualValues(t, 200, w.Code)
  18. assert.Contains(t, w.Body.String(), `class="page-content install"`)
  19. w = httptest.NewRecorder()
  20. req = httptest.NewRequest("GET", "/no-such", nil)
  21. r.ServeHTTP(w, req)
  22. assert.EqualValues(t, 404, w.Code)
  23. w = httptest.NewRecorder()
  24. req = httptest.NewRequest("GET", "/assets/img/gitea.svg", nil)
  25. r.ServeHTTP(w, req)
  26. assert.EqualValues(t, 200, w.Code)
  27. }
  28. func TestMain(m *testing.M) {
  29. unittest.MainTest(m, &unittest.TestOptions{
  30. GiteaRootPath: filepath.Join("..", ".."),
  31. })
  32. }