gitea源码

follow_test.go 731B

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