code.gitea.io/gitea@v1.21.7/services/repository/collaboration_test.go (about)

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