gtsocial-umbx

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

media_test.go (1988B)


      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 	"time"
     24 
     25 	"github.com/stretchr/testify/suite"
     26 	"github.com/superseriousbusiness/gotosocial/testrig"
     27 )
     28 
     29 type MediaTestSuite struct {
     30 	BunDBStandardTestSuite
     31 }
     32 
     33 func (suite *MediaTestSuite) TestGetAttachmentByID() {
     34 	testAttachment := suite.testAttachments["admin_account_status_1_attachment_1"]
     35 	attachment, err := suite.db.GetAttachmentByID(context.Background(), testAttachment.ID)
     36 	suite.NoError(err)
     37 	suite.NotNil(attachment)
     38 }
     39 
     40 func (suite *MediaTestSuite) TestGetOlder() {
     41 	attachments, err := suite.db.GetRemoteOlderThan(context.Background(), time.Now(), 20)
     42 	suite.NoError(err)
     43 	suite.Len(attachments, 2)
     44 }
     45 
     46 func (suite *MediaTestSuite) TestGetAvisAndHeaders() {
     47 	ctx := context.Background()
     48 
     49 	attachments, err := suite.db.GetAvatarsAndHeaders(ctx, "", 20)
     50 	suite.NoError(err)
     51 	suite.Len(attachments, 3)
     52 }
     53 
     54 func (suite *MediaTestSuite) TestGetLocalUnattachedOlderThan() {
     55 	ctx := context.Background()
     56 
     57 	attachments, err := suite.db.GetLocalUnattachedOlderThan(ctx, testrig.TimeMustParse("2090-06-04T13:12:00Z"), 10)
     58 	suite.NoError(err)
     59 	suite.Len(attachments, 1)
     60 }
     61 
     62 func TestMediaTestSuite(t *testing.T) {
     63 	suite.Run(t, new(MediaTestSuite))
     64 }