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.

api_repo_tags_test.go 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. "path"
  8. "testing"
  9. "code.gitea.io/gitea/models"
  10. "code.gitea.io/gitea/modules/setting"
  11. api "code.gitea.io/sdk/gitea"
  12. "github.com/stretchr/testify/assert"
  13. )
  14. func TestAPIReposGetTags(t *testing.T) {
  15. prepareTestEnv(t)
  16. user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
  17. // Login as User2.
  18. session := loginUser(t, user.Name)
  19. token := getTokenForLoggedInUser(t, session)
  20. req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/tags?token="+token, user.Name)
  21. resp := session.MakeRequest(t, req, http.StatusOK)
  22. var tags []*api.Tag
  23. DecodeJSON(t, resp, &tags)
  24. assert.EqualValues(t, 1, len(tags))
  25. assert.Equal(t, "v1.1", tags[0].Name)
  26. assert.Equal(t, "65f1bf27bc3bf70f64657658635e66094edbcb4d", tags[0].Commit.SHA)
  27. assert.Equal(t, path.Join(setting.AppSubURL, "/user2/repo1/commit/65f1bf27bc3bf70f64657658635e66094edbcb4d"), tags[0].Commit.URL)
  28. assert.Equal(t, path.Join(setting.AppSubURL, "/user2/repo1/archive/v1.1.zip"), tags[0].ZipballURL)
  29. assert.Equal(t, path.Join(setting.AppSubURL, "/user2/repo1/archive/v1.1.tar.gz"), tags[0].TarballURL)
  30. }