Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

api_repo_git_ref_test.go 1.1KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2018 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/unittest"
  9. user_model "code.gitea.io/gitea/models/user"
  10. )
  11. func TestAPIReposGitRefs(t *testing.T) {
  12. defer prepareTestEnv(t)()
  13. user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User)
  14. // Login as User2.
  15. session := loginUser(t, user.Name)
  16. token := getTokenForLoggedInUser(t, session)
  17. for _, ref := range [...]string{
  18. "refs/heads/master", // Branch
  19. "refs/tags/v1.1", // Tag
  20. } {
  21. req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/git/%s?token="+token, user.Name, ref)
  22. session.MakeRequest(t, req, http.StatusOK)
  23. }
  24. // Test getting all refs
  25. req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/git/refs?token="+token, user.Name)
  26. session.MakeRequest(t, req, http.StatusOK)
  27. // Test getting non-existent refs
  28. req = NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/git/refs/heads/unknown?token="+token, user.Name)
  29. session.MakeRequest(t, req, http.StatusNotFound)
  30. }