github.com/lologarithm/mattermost-server@v5.3.2-0.20181002060438-c82a84ed765b+incompatible/app/status_test.go (about)

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