github.com/adacta-ru/mattermost-server@v5.11.1+incompatible/app/user_terms_of_service_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/stretchr/testify/assert"
    10  )
    11  
    12  func TestUserTermsOfService(t *testing.T) {
    13  	th := Setup(t).InitBasic()
    14  	defer th.TearDown()
    15  
    16  	userTermsOfService, err := th.App.GetUserTermsOfService(th.BasicUser.Id)
    17  	checkError(t, err)
    18  	assert.Nil(t, userTermsOfService)
    19  	assert.Equal(t, "store.sql_user_terms_of_service.get_by_user.no_rows.app_error", err.Id)
    20  
    21  	termsOfService, err := th.App.CreateTermsOfService("terms of service", th.BasicUser.Id)
    22  	checkNoError(t, err)
    23  
    24  	err = th.App.SaveUserTermsOfService(th.BasicUser.Id, termsOfService.Id, true)
    25  	checkNoError(t, err)
    26  
    27  	userTermsOfService, err = th.App.GetUserTermsOfService(th.BasicUser.Id)
    28  	checkNoError(t, err)
    29  	assert.NotNil(t, userTermsOfService)
    30  	assert.NotEmpty(t, userTermsOfService)
    31  
    32  	assert.Equal(t, th.BasicUser.Id, userTermsOfService.UserId)
    33  	assert.Equal(t, termsOfService.Id, userTermsOfService.TermsOfServiceId)
    34  	assert.NotEmpty(t, userTermsOfService.CreateAt)
    35  }