You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

repo_test.go 1.2 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2017 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. "testing"
  8. "github.com/stretchr/testify/assert"
  9. )
  10. func TestViewRepo(t *testing.T) {
  11. prepareTestEnv(t)
  12. req := NewRequest(t, "GET", "/user2/repo1")
  13. resp := MakeRequest(req)
  14. assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
  15. req = NewRequest(t, "GET", "/user3/repo3")
  16. resp = MakeRequest(req)
  17. assert.EqualValues(t, http.StatusNotFound, resp.HeaderCode)
  18. session := loginUser(t, "user1", "password")
  19. resp = session.MakeRequest(t, req)
  20. assert.EqualValues(t, http.StatusNotFound, resp.HeaderCode)
  21. }
  22. func TestViewRepo2(t *testing.T) {
  23. prepareTestEnv(t)
  24. req := NewRequest(t, "GET", "/user3/repo3")
  25. session := loginUser(t, "user2", "password")
  26. resp := session.MakeRequest(t, req)
  27. assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
  28. }
  29. func TestViewRepo3(t *testing.T) {
  30. prepareTestEnv(t)
  31. req := NewRequest(t, "GET", "/user3/repo3")
  32. session := loginUser(t, "user3", "password")
  33. resp := session.MakeRequest(t, req)
  34. assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
  35. }