status_test.go 891 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
  2. // See LICENSE.txt for license information.
  3. package app
  4. import (
  5. "testing"
  6. "github.com/mattermost/mattermost-server/v5/model"
  7. "github.com/stretchr/testify/require"
  8. )
  9. func TestSaveStatus(t *testing.T) {
  10. th := Setup(t).InitBasic()
  11. defer th.TearDown()
  12. user := th.BasicUser
  13. for _, statusString := range []string{
  14. model.STATUS_ONLINE,
  15. model.STATUS_AWAY,
  16. model.STATUS_DND,
  17. model.STATUS_OFFLINE,
  18. } {
  19. t.Run(statusString, func(t *testing.T) {
  20. status := &model.Status{
  21. UserId: user.Id,
  22. Status: statusString,
  23. }
  24. th.App.SaveAndBroadcastStatus(status)
  25. after, err := th.App.GetStatus(user.Id)
  26. require.Nil(t, err, "failed to get status after save: %v", err)
  27. require.Equal(t, statusString, after.Status, "failed to save status, got %v, expected %v", after.Status, statusString)
  28. })
  29. }
  30. }