2019-11-29 12:59:40 +01:00
|
|
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
|
|
|
// See LICENSE.txt for license information.
|
2018-11-09 02:18:14 +05:30
|
|
|
|
|
|
|
|
package model
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"strings"
|
|
|
|
|
"testing"
|
2018-11-28 10:56:21 -08:00
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2019-10-11 15:06:11 +02:00
|
|
|
"github.com/stretchr/testify/require"
|
2018-11-09 02:18:14 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestUserTermsOfServiceIsValid(t *testing.T) {
|
|
|
|
|
s := UserTermsOfService{}
|
2019-10-11 15:06:11 +02:00
|
|
|
require.Error(t, s.IsValid(), "should be invalid")
|
2018-11-09 02:18:14 +05:30
|
|
|
|
|
|
|
|
s.UserId = NewId()
|
2019-10-11 15:06:11 +02:00
|
|
|
require.Error(t, s.IsValid(), "should be invalid")
|
2018-11-09 02:18:14 +05:30
|
|
|
|
|
|
|
|
s.TermsOfServiceId = NewId()
|
2019-10-11 15:06:11 +02:00
|
|
|
require.Error(t, s.IsValid(), "should be invalid")
|
2018-11-09 02:18:14 +05:30
|
|
|
|
|
|
|
|
s.CreateAt = GetMillis()
|
2019-10-11 15:06:11 +02:00
|
|
|
require.Nil(t, s.IsValid(), "should be valid")
|
2018-11-09 02:18:14 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestUserTermsOfServiceJson(t *testing.T) {
|
|
|
|
|
o := UserTermsOfService{
|
|
|
|
|
UserId: NewId(),
|
|
|
|
|
TermsOfServiceId: NewId(),
|
|
|
|
|
CreateAt: GetMillis(),
|
|
|
|
|
}
|
|
|
|
|
j := o.ToJson()
|
|
|
|
|
ro := UserTermsOfServiceFromJson(strings.NewReader(j))
|
|
|
|
|
|
|
|
|
|
assert.NotNil(t, ro)
|
|
|
|
|
assert.Equal(t, o, *ro)
|
|
|
|
|
}
|