emojicategoriesget_test.go (1834B)
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 admin_test 19 20 import ( 21 "bytes" 22 "encoding/json" 23 "io" 24 "net/http" 25 "net/http/httptest" 26 "testing" 27 28 "github.com/stretchr/testify/suite" 29 "github.com/superseriousbusiness/gotosocial/internal/api/client/admin" 30 ) 31 32 type EmojiCategoriesGetTestSuite struct { 33 AdminStandardTestSuite 34 } 35 36 func (suite *EmojiCategoriesGetTestSuite) TestEmojiCategoriesGet() { 37 recorder := httptest.NewRecorder() 38 39 path := admin.EmojiCategoriesPath 40 ctx := suite.newContext(recorder, http.MethodGet, nil, path, "application/json") 41 42 suite.adminModule.EmojiCategoriesGETHandler(ctx) 43 suite.Equal(http.StatusOK, recorder.Code) 44 45 b, err := io.ReadAll(recorder.Body) 46 suite.NoError(err) 47 suite.NotNil(b) 48 dst := new(bytes.Buffer) 49 err = json.Indent(dst, b, "", " ") 50 suite.NoError(err) 51 suite.Equal(`[ 52 { 53 "id": "01GGQ989PTT9PMRN4FZ1WWK2B9", 54 "name": "cute stuff" 55 }, 56 { 57 "id": "01GGQ8V4993XK67B2JB396YFB7", 58 "name": "reactions" 59 } 60 ]`, dst.String()) 61 } 62 63 func TestEmojiCategoriesGetTestSuite(t *testing.T) { 64 suite.Run(t, &EmojiCategoriesGetTestSuite{}) 65 }