github.com/turgay/mattermost-server@v5.3.2-0.20181002173352-2945e8a2b0ce+incompatible/api4/service_terms_test.go (about)

     1  package api4
     2  
     3  import (
     4  	"github.com/mattermost/mattermost-server/model"
     5  	"github.com/stretchr/testify/assert"
     6  	"testing"
     7  )
     8  
     9  func TestGetServiceTerms(t *testing.T) {
    10  	th := Setup().InitBasic()
    11  	defer th.TearDown()
    12  	Client := th.Client
    13  
    14  	_, err := th.App.CreateServiceTerms("abc", th.BasicUser.Id)
    15  	if err != nil {
    16  		t.Fatal(err)
    17  	}
    18  
    19  	serviceTerms, resp := Client.GetServiceTerms("")
    20  	CheckNoError(t, resp)
    21  
    22  	assert.NotNil(t, serviceTerms)
    23  	assert.Equal(t, "abc", serviceTerms.Text)
    24  	assert.NotEmpty(t, serviceTerms.Id)
    25  	assert.NotEmpty(t, serviceTerms.CreateAt)
    26  }
    27  
    28  func TestCreateServiceTerms(t *testing.T) {
    29  	th := Setup().InitBasic()
    30  	defer th.TearDown()
    31  	Client := th.Client
    32  
    33  	serviceTerms, resp := Client.CreateServiceTerms("service terms new", th.BasicUser.Id)
    34  	CheckErrorMessage(t, resp, "api.create_service_terms.custom_service_terms_disabled.app_error")
    35  
    36  	th.App.SetLicense(model.NewTestLicense("EnableCustomServiceTerms"))
    37  
    38  	serviceTerms, resp = Client.CreateServiceTerms("service terms new", th.BasicUser.Id)
    39  	CheckNoError(t, resp)
    40  	assert.NotEmpty(t, serviceTerms.Id)
    41  	assert.NotEmpty(t, serviceTerms.CreateAt)
    42  	assert.Equal(t, "service terms new", serviceTerms.Text)
    43  	assert.Equal(t, th.BasicUser.Id, serviceTerms.UserId)
    44  }