Fork to maintain patches against the official gitea for https://code.ceondo.com https://github.com/go-gitea/gitea

api_repo_raw_test.go 868B

1234567891011121314151617181920212223242526272829303132
  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. "code.gitea.io/gitea/models"
  9. )
  10. func TestAPIReposRaw(t *testing.T) {
  11. prepareTestEnv(t)
  12. user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
  13. // Login as User2.
  14. session := loginUser(t, user.Name)
  15. for _, ref := range [...]string{
  16. "master", // Branch
  17. "v1.1", // Tag
  18. "65f1bf27bc3bf70f64657658635e66094edbcb4d", // Commit
  19. } {
  20. req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/raw/%s/README.md", user.Name, ref)
  21. session.MakeRequest(t, req, http.StatusOK)
  22. }
  23. // Test default branch
  24. req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/raw/README.md", user.Name)
  25. session.MakeRequest(t, req, http.StatusOK)
  26. }