code.gitea.io/gitea@v1.21.7/models/user/follow_test.go (about)

     1  // Copyright 2020 The Gitea Authors. All rights reserved.
     2  // SPDX-License-Identifier: MIT
     3  
     4  package user_test
     5  
     6  import (
     7  	"testing"
     8  
     9  	"code.gitea.io/gitea/models/db"
    10  	"code.gitea.io/gitea/models/unittest"
    11  	user_model "code.gitea.io/gitea/models/user"
    12  
    13  	"github.com/stretchr/testify/assert"
    14  )
    15  
    16  func TestIsFollowing(t *testing.T) {
    17  	assert.NoError(t, unittest.PrepareTestDatabase())
    18  	assert.True(t, user_model.IsFollowing(db.DefaultContext, 4, 2))
    19  	assert.False(t, user_model.IsFollowing(db.DefaultContext, 2, 4))
    20  	assert.False(t, user_model.IsFollowing(db.DefaultContext, 5, unittest.NonexistentID))
    21  	assert.False(t, user_model.IsFollowing(db.DefaultContext, unittest.NonexistentID, 5))
    22  	assert.False(t, user_model.IsFollowing(db.DefaultContext, unittest.NonexistentID, unittest.NonexistentID))
    23  }