gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

search_test.go (2745B)


      1 // GoToSocial
      2 // Copyright (C) GoToSocial Authors admin@gotosocial.org
      3 // SPDX-License-Identifier: AGPL-3.0-or-later
      4 //
      5 // This program is free software: you can redistribute it and/or modify
      6 // it under the terms of the GNU Affero General Public License as published by
      7 // the Free Software Foundation, either version 3 of the License, or
      8 // (at your option) any later version.
      9 //
     10 // This program is distributed in the hope that it will be useful,
     11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 // GNU Affero General Public License for more details.
     14 //
     15 // You should have received a copy of the GNU Affero General Public License
     16 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
     17 
     18 package bundb_test
     19 
     20 import (
     21 	"context"
     22 	"testing"
     23 
     24 	"github.com/stretchr/testify/suite"
     25 	"github.com/superseriousbusiness/gotosocial/internal/db"
     26 )
     27 
     28 type SearchTestSuite struct {
     29 	BunDBStandardTestSuite
     30 }
     31 
     32 func (suite *SearchTestSuite) TestSearchAccountsTurtleAny() {
     33 	testAccount := suite.testAccounts["local_account_1"]
     34 
     35 	accounts, err := suite.db.SearchForAccounts(context.Background(), testAccount.ID, "turtle", "", "", 10, false, 0)
     36 	suite.NoError(err)
     37 	suite.Len(accounts, 1)
     38 }
     39 
     40 func (suite *SearchTestSuite) TestSearchAccountsTurtleFollowing() {
     41 	testAccount := suite.testAccounts["local_account_1"]
     42 
     43 	accounts, err := suite.db.SearchForAccounts(context.Background(), testAccount.ID, "turtle", "", "", 10, true, 0)
     44 	suite.NoError(err)
     45 	suite.Len(accounts, 1)
     46 }
     47 
     48 func (suite *SearchTestSuite) TestSearchAccountsPostFollowing() {
     49 	testAccount := suite.testAccounts["local_account_1"]
     50 
     51 	accounts, err := suite.db.SearchForAccounts(context.Background(), testAccount.ID, "post", "", "", 10, true, 0)
     52 	suite.NoError(err)
     53 	suite.Len(accounts, 1)
     54 }
     55 
     56 func (suite *SearchTestSuite) TestSearchAccountsPostAny() {
     57 	testAccount := suite.testAccounts["local_account_1"]
     58 
     59 	accounts, err := suite.db.SearchForAccounts(context.Background(), testAccount.ID, "post", "", "", 10, false, 0)
     60 	suite.NoError(err, db.ErrNoEntries)
     61 	suite.Empty(accounts)
     62 }
     63 
     64 func (suite *SearchTestSuite) TestSearchAccountsFossAny() {
     65 	testAccount := suite.testAccounts["local_account_1"]
     66 
     67 	accounts, err := suite.db.SearchForAccounts(context.Background(), testAccount.ID, "foss", "", "", 10, false, 0)
     68 	suite.NoError(err)
     69 	suite.Len(accounts, 1)
     70 }
     71 
     72 func (suite *SearchTestSuite) TestSearchStatuses() {
     73 	testAccount := suite.testAccounts["local_account_1"]
     74 
     75 	statuses, err := suite.db.SearchForStatuses(context.Background(), testAccount.ID, "hello", "", "", 10, 0)
     76 	suite.NoError(err)
     77 	suite.Len(statuses, 1)
     78 }
     79 
     80 func TestSearchTestSuite(t *testing.T) {
     81 	suite.Run(t, new(SearchTestSuite))
     82 }