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.

collaboration_test.go 1.0KB

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2017 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package repository
  4. import (
  5. "testing"
  6. "code.gitea.io/gitea/models/db"
  7. repo_model "code.gitea.io/gitea/models/repo"
  8. "code.gitea.io/gitea/models/unittest"
  9. user_model "code.gitea.io/gitea/models/user"
  10. "github.com/stretchr/testify/assert"
  11. )
  12. func TestRepository_DeleteCollaboration(t *testing.T) {
  13. assert.NoError(t, unittest.PrepareTestDatabase())
  14. user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 4})
  15. repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 4})
  16. assert.NoError(t, repo.LoadOwner(db.DefaultContext))
  17. assert.NoError(t, DeleteCollaboration(db.DefaultContext, repo, user))
  18. unittest.AssertNotExistsBean(t, &repo_model.Collaboration{RepoID: repo.ID, UserID: user.ID})
  19. assert.NoError(t, DeleteCollaboration(db.DefaultContext, repo, user))
  20. unittest.AssertNotExistsBean(t, &repo_model.Collaboration{RepoID: repo.ID, UserID: user.ID})
  21. unittest.CheckConsistencyFor(t, &repo_model.Repository{ID: repo.ID})
  22. }