summaryrefslogtreecommitdiffstats
path: root/app/status_test.go
blob: bf5736a48b5e19d4605394ebd16c43bf85889b1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

package app

import (
	"testing"

	"github.com/mattermost/mattermost-server/model"
)

func TestSaveStatus(t *testing.T) {
	th := Setup().InitBasic()
	defer th.TearDown()

	user := th.BasicUser

	for _, statusString := range []string{
		model.STATUS_ONLINE,
		model.STATUS_AWAY,
		model.STATUS_DND,
		model.STATUS_OFFLINE,
	} {
		t.Run(statusString, func(t *testing.T) {
			status := &model.Status{
				UserId: user.Id,
				Status: statusString,
			}

			th.App.SaveAndBroadcastStatus(status)

			after, err := th.App.GetStatus(user.Id)
			if err != nil {
				t.Fatalf("failed to get status after save: %v", err)
			} else if after.Status != statusString {
				t.Fatalf("failed to save status, got %v, expected %v", after.Status, statusString)
			}
		})
	}
}