diff options
author | Martin Kraft <martinkraft@gmail.com> | 2018-03-27 09:01:42 -0400 |
---|---|---|
committer | Martin Kraft <martinkraft@gmail.com> | 2018-03-27 09:01:42 -0400 |
commit | e13e64711f7a7e8ceadb8cbc6af72c4022c95b36 (patch) | |
tree | fe0e956b1d660cd08d41757d25c8adcb3463568c /app/post_test.go | |
parent | d8b42070186c12f6320fe54ea1c405149846404c (diff) | |
parent | 9e6db178b09387e21ac19ce85369cf1ca7a443e8 (diff) | |
download | chat-e13e64711f7a7e8ceadb8cbc6af72c4022c95b36.tar.gz chat-e13e64711f7a7e8ceadb8cbc6af72c4022c95b36.tar.bz2 chat-e13e64711f7a7e8ceadb8cbc6af72c4022c95b36.zip |
Merge remote-tracking branch 'origin/master' into advanced-permissions-phase-1
Diffstat (limited to 'app/post_test.go')
-rw-r--r-- | app/post_test.go | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/app/post_test.go b/app/post_test.go index 2e499d3b3..10b957751 100644 --- a/app/post_test.go +++ b/app/post_test.go @@ -9,6 +9,7 @@ import ( "net/http" "net/http/httptest" "strings" + "sync/atomic" "testing" "time" @@ -17,6 +18,8 @@ import ( "github.com/stretchr/testify/require" "github.com/mattermost/mattermost-server/model" + "github.com/mattermost/mattermost-server/store" + "github.com/mattermost/mattermost-server/store/storetest" ) func TestUpdatePostEditAt(t *testing.T) { @@ -383,3 +386,59 @@ func TestMakeOpenGraphURLsAbsolute(t *testing.T) { }) } } + +func TestMaxPostSize(t *testing.T) { + t.Parallel() + + testCases := []struct { + Description string + StoreMaxPostSize int + ExpectedMaxPostSize int + ExpectedError *model.AppError + }{ + { + "error fetching max post size", + 0, + model.POST_MESSAGE_MAX_RUNES_V1, + model.NewAppError("TestMaxPostSize", "this is an error", nil, "", http.StatusBadRequest), + }, + { + "4000 rune limit", + 4000, + 4000, + nil, + }, + { + "16383 rune limit", + 16383, + 16383, + nil, + }, + } + + for _, testCase := range testCases { + testCase := testCase + t.Run(testCase.Description, func(t *testing.T) { + t.Parallel() + + mockStore := &storetest.Store{} + defer mockStore.AssertExpectations(t) + + mockStore.PostStore.On("GetMaxPostSize").Return( + storetest.NewStoreChannel(store.StoreResult{ + Data: testCase.StoreMaxPostSize, + Err: testCase.ExpectedError, + }), + ) + + app := App{ + Srv: &Server{ + Store: mockStore, + }, + config: atomic.Value{}, + } + + assert.Equal(t, testCase.ExpectedMaxPostSize, app.MaxPostSize()) + }) + } +} |