preferences_test.go (2166B)
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 processing_test 19 20 import ( 21 "context" 22 "testing" 23 24 "github.com/stretchr/testify/suite" 25 "github.com/superseriousbusiness/gotosocial/internal/api/model" 26 "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" 27 ) 28 29 type PreferencesTestSuite struct { 30 ProcessingStandardTestSuite 31 } 32 33 func (suite *PreferencesTestSuite) TestPreferencesGet() { 34 ctx := context.Background() 35 tests := []struct { 36 act *gtsmodel.Account 37 prefs *model.Preferences 38 }{ 39 { 40 act: suite.testAccounts["local_account_1"], 41 prefs: &model.Preferences{ 42 PostingDefaultVisibility: "public", 43 PostingDefaultSensitive: false, 44 PostingDefaultLanguage: "en", 45 ReadingExpandMedia: "default", 46 ReadingExpandSpoilers: false, 47 ReadingAutoPlayGifs: false, 48 }, 49 }, 50 { 51 act: suite.testAccounts["local_account_2"], 52 prefs: &model.Preferences{ 53 PostingDefaultVisibility: "private", 54 PostingDefaultSensitive: true, 55 PostingDefaultLanguage: "fr", 56 ReadingExpandMedia: "default", 57 ReadingExpandSpoilers: false, 58 ReadingAutoPlayGifs: false, 59 }, 60 }, 61 } 62 63 for _, tt := range tests { 64 suite.Run(tt.act.ID, func() { 65 prefs, err := suite.processor.PreferencesGet(ctx, tt.act.ID) 66 suite.NoError(err) 67 suite.Equal(tt.prefs, prefs) 68 }) 69 } 70 } 71 72 func TestPreferencesTestSuite(t *testing.T) { 73 suite.Run(t, &PreferencesTestSuite{}) 74 }