mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* Moving app from singular to being created for every request. * Automatic refactor * Adding license header * Feedback fixes
36 lines
1.0 KiB
Go
36 lines
1.0 KiB
Go
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
package app
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestUserTermsOfService(t *testing.T) {
|
|
th := Setup().InitBasic()
|
|
defer th.TearDown()
|
|
|
|
userTermsOfService, err := th.App.GetUserTermsOfService(th.BasicUser.Id)
|
|
checkError(t, err)
|
|
assert.Nil(t, userTermsOfService)
|
|
assert.Equal(t, "store.sql_user_terms_of_service.get_by_user.no_rows.app_error", err.Id)
|
|
|
|
termsOfService, err := th.App.CreateTermsOfService("terms of service", th.BasicUser.Id)
|
|
checkNoError(t, err)
|
|
|
|
err = th.App.SaveUserTermsOfService(th.BasicUser.Id, termsOfService.Id, true)
|
|
checkNoError(t, err)
|
|
|
|
userTermsOfService, err = th.App.GetUserTermsOfService(th.BasicUser.Id)
|
|
checkNoError(t, err)
|
|
assert.NotNil(t, userTermsOfService)
|
|
assert.NotEmpty(t, userTermsOfService)
|
|
|
|
assert.Equal(t, th.BasicUser.Id, userTermsOfService.UserId)
|
|
assert.Equal(t, termsOfService.Id, userTermsOfService.TermsOfServiceId)
|
|
assert.NotEmpty(t, userTermsOfService.CreateAt)
|
|
}
|