github.com/haalcala/mattermost-server-change-repo/v5@v5.33.2/model/system_test.go (about)

     1  // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
     2  // See LICENSE.txt for license information.
     3  
     4  package model
     5  
     6  import (
     7  	"strings"
     8  	"testing"
     9  	"time"
    10  
    11  	"github.com/stretchr/testify/require"
    12  )
    13  
    14  func TestSystemJson(t *testing.T) {
    15  	system := System{Name: "test", Value: NewId()}
    16  	json := system.ToJson()
    17  	result := SystemFromJson(strings.NewReader(json))
    18  
    19  	require.Equal(t, "test", result.Name, "ids do not match")
    20  }
    21  
    22  func TestServerBusyJson(t *testing.T) {
    23  	now := time.Now()
    24  	sbs := ServerBusyState{Busy: true, Expires: now.Unix()}
    25  	json := sbs.ToJson()
    26  	result := ServerBusyStateFromJson(strings.NewReader(json))
    27  
    28  	require.Equal(t, sbs.Busy, result.Busy, "busy state does not match")
    29  	require.Equal(t, sbs.Expires, result.Expires, "expiry does not match")
    30  }