2021-11-17 10:58:31 +01:00
|
|
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
2022-11-27 19:20:29 +01:00
|
|
|
// SPDX-License-Identifier: MIT
|
2021-11-17 10:58:31 +01:00
|
|
|
|
2022-06-15 09:02:00 +02:00
|
|
|
package user_test
|
2021-11-17 10:58:31 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-09-16 16:39:12 +02:00
|
|
|
"code.gitea.io/gitea/models/db"
|
2021-11-17 10:58:31 +01:00
|
|
|
"code.gitea.io/gitea/models/unittest"
|
2022-06-15 09:02:00 +02:00
|
|
|
user_model "code.gitea.io/gitea/models/user"
|
2021-11-17 10:58:31 +01:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2024-07-30 21:42:06 +02:00
|
|
|
"github.com/stretchr/testify/require"
|
2021-11-17 10:58:31 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestIsFollowing(t *testing.T) {
|
2024-07-30 21:42:06 +02:00
|
|
|
require.NoError(t, unittest.PrepareTestDatabase())
|
2023-09-16 16:39:12 +02:00
|
|
|
assert.True(t, user_model.IsFollowing(db.DefaultContext, 4, 2))
|
|
|
|
assert.False(t, user_model.IsFollowing(db.DefaultContext, 2, 4))
|
|
|
|
assert.False(t, user_model.IsFollowing(db.DefaultContext, 5, unittest.NonexistentID))
|
|
|
|
assert.False(t, user_model.IsFollowing(db.DefaultContext, unittest.NonexistentID, 5))
|
|
|
|
assert.False(t, user_model.IsFollowing(db.DefaultContext, unittest.NonexistentID, unittest.NonexistentID))
|
2021-11-17 10:58:31 +01:00
|
|
|
}
|