Full Mattermost server source with integrated Community Enterprise features. Includes vendor directory for offline/air-gapped builds. Structure: - enterprise-impl/: Enterprise feature implementations - enterprise-community/: Init files that register implementations - enterprise/: Bridge imports (community_imports.go) - vendor/: All dependencies for offline builds Build (online): go build ./cmd/mattermost Build (offline/air-gapped): go build -mod=vendor ./cmd/mattermost 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
134 lines
3.9 KiB
Go
134 lines
3.9 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package app
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/mattermost/mattermost/server/public/model"
|
|
"github.com/mattermost/mattermost/server/public/shared/request"
|
|
"github.com/mattermost/mattermost/server/v8/channels/utils"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func BenchmarkUploadEmojiImage(b *testing.B) {
|
|
th := Setup(b)
|
|
b.Cleanup(func() {
|
|
th.TearDown()
|
|
})
|
|
|
|
rctx := request.TestContext(b)
|
|
|
|
b.Run("gif", func(b *testing.B) {
|
|
filename := "image.gif"
|
|
b.Run("small", func(b *testing.B) {
|
|
file := strings.NewReader(string(utils.CreateTestGif(b, 10, 10)))
|
|
for b.Loop() {
|
|
id := model.NewId()
|
|
appErr := th.App.uploadEmojiImage(rctx, id, filename, file)
|
|
require.Nil(b, appErr)
|
|
_, err := file.Seek(0, 0)
|
|
require.NoError(b, err)
|
|
}
|
|
})
|
|
b.Run("max size", func(b *testing.B) {
|
|
file := strings.NewReader(string(utils.CreateTestGif(b, MaxEmojiWidth, MaxEmojiHeight)))
|
|
for b.Loop() {
|
|
id := model.NewId()
|
|
appErr := th.App.uploadEmojiImage(rctx, id, filename, file)
|
|
require.Nil(b, appErr)
|
|
_, err := file.Seek(0, 0)
|
|
require.NoError(b, err)
|
|
}
|
|
})
|
|
b.Run("too wide", func(b *testing.B) {
|
|
file := strings.NewReader(string(utils.CreateTestGif(b, MaxEmojiOriginalWidth, MaxEmojiHeight)))
|
|
for b.Loop() {
|
|
id := model.NewId()
|
|
appErr := th.App.uploadEmojiImage(rctx, id, filename, file)
|
|
require.Nil(b, appErr)
|
|
_, err := file.Seek(0, 0)
|
|
require.NoError(b, err)
|
|
}
|
|
})
|
|
b.Run("too tall", func(b *testing.B) {
|
|
file := strings.NewReader(string(utils.CreateTestGif(b, MaxEmojiWidth, MaxEmojiOriginalWidth)))
|
|
for b.Loop() {
|
|
id := model.NewId()
|
|
appErr := th.App.uploadEmojiImage(rctx, id, filename, file)
|
|
require.Nil(b, appErr)
|
|
_, err := file.Seek(0, 0)
|
|
require.NoError(b, err)
|
|
}
|
|
})
|
|
b.Run("too tall and too wide", func(b *testing.B) {
|
|
file := strings.NewReader(string(utils.CreateTestGif(b, MaxEmojiOriginalWidth, MaxEmojiOriginalWidth)))
|
|
for b.Loop() {
|
|
id := model.NewId()
|
|
appErr := th.App.uploadEmojiImage(rctx, id, filename, file)
|
|
require.Nil(b, appErr)
|
|
_, err := file.Seek(0, 0)
|
|
require.NoError(b, err)
|
|
}
|
|
})
|
|
})
|
|
|
|
b.Run("png", func(b *testing.B) {
|
|
filename := "image.png"
|
|
|
|
b.Run("small", func(b *testing.B) {
|
|
file := strings.NewReader(string(utils.CreateTestPng(b, 10, 10)))
|
|
for b.Loop() {
|
|
id := model.NewId()
|
|
appErr := th.App.uploadEmojiImage(rctx, id, filename, file)
|
|
require.Nil(b, appErr)
|
|
_, err := file.Seek(0, 0)
|
|
require.NoError(b, err)
|
|
}
|
|
})
|
|
|
|
b.Run("max size", func(b *testing.B) {
|
|
file := strings.NewReader(string(utils.CreateTestPng(b, MaxEmojiWidth, MaxEmojiHeight)))
|
|
for b.Loop() {
|
|
id := model.NewId()
|
|
appErr := th.App.uploadEmojiImage(rctx, id, filename, file)
|
|
require.Nil(b, appErr)
|
|
_, err := file.Seek(0, 0)
|
|
require.NoError(b, err)
|
|
}
|
|
})
|
|
b.Run("too wide", func(b *testing.B) {
|
|
file := strings.NewReader(string(utils.CreateTestPng(b, MaxEmojiOriginalWidth, MaxEmojiHeight)))
|
|
for b.Loop() {
|
|
id := model.NewId()
|
|
appErr := th.App.uploadEmojiImage(rctx, id, filename, file)
|
|
require.Nil(b, appErr)
|
|
_, err := file.Seek(0, 0)
|
|
require.NoError(b, err)
|
|
}
|
|
})
|
|
b.Run("too tall", func(b *testing.B) {
|
|
file := strings.NewReader(string(utils.CreateTestPng(b, MaxEmojiWidth, MaxEmojiOriginalWidth)))
|
|
for b.Loop() {
|
|
id := model.NewId()
|
|
appErr := th.App.uploadEmojiImage(rctx, id, filename, file)
|
|
require.Nil(b, appErr)
|
|
_, err := file.Seek(0, 0)
|
|
require.NoError(b, err)
|
|
}
|
|
})
|
|
b.Run("too tall and too wide", func(b *testing.B) {
|
|
file := strings.NewReader(string(utils.CreateTestPng(b, MaxEmojiOriginalWidth, MaxEmojiOriginalWidth)))
|
|
for b.Loop() {
|
|
id := model.NewId()
|
|
appErr := th.App.uploadEmojiImage(rctx, id, filename, file)
|
|
require.Nil(b, appErr)
|
|
_, err := file.Seek(0, 0)
|
|
require.NoError(b, err)
|
|
}
|
|
})
|
|
})
|
|
}
|