Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2019 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 action
  5. import (
  6. "path/filepath"
  7. "strings"
  8. "testing"
  9. "code.gitea.io/gitea/models"
  10. "github.com/stretchr/testify/assert"
  11. )
  12. func TestMain(m *testing.M) {
  13. models.MainTest(m, filepath.Join("..", "..", ".."))
  14. }
  15. func TestRenameRepoAction(t *testing.T) {
  16. assert.NoError(t, models.PrepareTestDatabase())
  17. user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
  18. repo := models.AssertExistsAndLoadBean(t, &models.Repository{OwnerID: user.ID}).(*models.Repository)
  19. repo.Owner = user
  20. oldRepoName := repo.Name
  21. const newRepoName = "newRepoName"
  22. repo.Name = newRepoName
  23. repo.LowerName = strings.ToLower(newRepoName)
  24. actionBean := &models.Action{
  25. OpType: models.ActionRenameRepo,
  26. ActUserID: user.ID,
  27. ActUser: user,
  28. RepoID: repo.ID,
  29. Repo: repo,
  30. IsPrivate: repo.IsPrivate,
  31. Content: oldRepoName,
  32. }
  33. models.AssertNotExistsBean(t, actionBean)
  34. NewNotifier().NotifyRenameRepository(user, repo, oldRepoName)
  35. models.AssertExistsAndLoadBean(t, actionBean)
  36. models.CheckConsistencyFor(t, &models.Action{})
  37. }