diff options
author | 2021-04-19 19:42:19 +0200 | |
---|---|---|
committer | 2021-04-19 19:42:19 +0200 | |
commit | 32c5fd987a06e11b14a4247d13187657c14adedd (patch) | |
tree | f5b787ca0f020bea5fd020925e52d3592a77a6ad /internal/media/media_test.go | |
parent | Api/v1/accounts (#8) (diff) | |
download | gotosocial-32c5fd987a06e11b14a4247d13187657c14adedd.tar.xz |
Api/v1/statuses (#11)
This PR adds:
Statuses
New status creation.
View existing status
Delete a status
Fave a status
Unfave a status
See who's faved a status
Media
Upload media attachment and store/retrieve it
Upload custom emoji and store/retrieve it
Fileserver
Serve files from storage
Testing
Test models, testrig -- run a GTS test instance and play around with it.
Diffstat (limited to 'internal/media/media_test.go')
-rw-r--r-- | internal/media/media_test.go | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/internal/media/media_test.go b/internal/media/media_test.go index ae5896c38..58f2e029e 100644 --- a/internal/media/media_test.go +++ b/internal/media/media_test.go @@ -29,7 +29,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/db" - "github.com/superseriousbusiness/gotosocial/internal/db/model" + "github.com/superseriousbusiness/gotosocial/internal/db/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/storage" ) @@ -95,7 +95,6 @@ func (suite *MediaTestSuite) SetupSuite() { storage: suite.mockStorage, log: log, } - } func (suite *MediaTestSuite) TearDownSuite() { @@ -108,14 +107,19 @@ func (suite *MediaTestSuite) TearDownSuite() { func (suite *MediaTestSuite) SetupTest() { // create all the tables we might need in thie suite models := []interface{}{ - &model.Account{}, - &model.MediaAttachment{}, + >smodel.Account{}, + >smodel.MediaAttachment{}, } for _, m := range models { if err := suite.db.CreateTable(m); err != nil { logrus.Panicf("db connection error: %s", err) } } + + err := suite.db.CreateInstanceAccount() + if err != nil { + logrus.Panic(err) + } } // TearDownTest drops tables to make sure there's no data in the db @@ -123,8 +127,8 @@ func (suite *MediaTestSuite) TearDownTest() { // remove all the tables we might have used so it's clear for the next test models := []interface{}{ - &model.Account{}, - &model.MediaAttachment{}, + >smodel.Account{}, + >smodel.MediaAttachment{}, } for _, m := range models { if err := suite.db.DropTable(m); err != nil { @@ -142,7 +146,7 @@ func (suite *MediaTestSuite) TestSetHeaderOrAvatarForAccountID() { f, err := ioutil.ReadFile("./test/test-jpeg.jpg") assert.Nil(suite.T(), err) - ma, err := suite.mediaHandler.SetHeaderOrAvatarForAccountID(f, "weeeeeee", "header") + ma, err := suite.mediaHandler.ProcessHeaderOrAvatar(f, "weeeeeee", "header") assert.Nil(suite.T(), err) suite.log.Debugf("%+v", ma) @@ -152,6 +156,15 @@ func (suite *MediaTestSuite) TestSetHeaderOrAvatarForAccountID() { //TODO: add more checks here, cba right now! } +func (suite *MediaTestSuite) TestProcessLocalEmoji() { + f, err := ioutil.ReadFile("./test/rainbow-original.png") + assert.NoError(suite.T(), err) + + emoji, err := suite.mediaHandler.ProcessLocalEmoji(f, "rainbow") + assert.NoError(suite.T(), err) + suite.log.Debugf("%+v", emoji) +} + // TODO: add tests for sad path, gif, png.... func TestMediaTestSuite(t *testing.T) { |