github.com/gigforks/mattermost-server@v4.9.1-0.20180619094218-800d97fa55d0+incompatible/api/license_test.go (about) 1 // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. 2 // See License.txt for license information. 3 4 package api 5 6 import ( 7 "testing" 8 ) 9 10 func TestGetLicenceConfig(t *testing.T) { 11 th := Setup().InitBasic() 12 defer th.TearDown() 13 14 Client := th.BasicClient 15 16 if result, err := Client.GetClientLicenceConfig(""); err != nil { 17 t.Fatal(err) 18 } else { 19 cfg := result.Data.(map[string]string) 20 21 if _, ok := cfg["IsLicensed"]; !ok { 22 t.Fatal(cfg) 23 } 24 25 // test etag caching 26 if cache_result, err := Client.GetClientLicenceConfig(result.Etag); err != nil { 27 t.Fatal(err) 28 } else if len(cache_result.Data.(map[string]string)) != 0 { 29 t.Log(cache_result.Data) 30 t.Fatal("cache should be empty") 31 } 32 33 th.App.SetClientLicense(map[string]string{"IsLicensed": "true"}) 34 35 if cache_result, err := Client.GetClientLicenceConfig(result.Etag); err != nil { 36 t.Fatal(err) 37 } else if len(cache_result.Data.(map[string]string)) == 0 { 38 t.Fatal("result should not be empty") 39 } 40 41 th.App.SetClientLicense(map[string]string{"SomeFeature": "true", "IsLicensed": "true"}) 42 43 if cache_result, err := Client.GetClientLicenceConfig(result.Etag); err != nil { 44 t.Fatal(err) 45 } else if len(cache_result.Data.(map[string]string)) == 0 { 46 t.Fatal("result should not be empty") 47 } 48 49 th.App.SetClientLicense(map[string]string{"IsLicensed": "false"}) 50 } 51 }