github.com/gigforks/mattermost-server@v4.9.1-0.20180619094218-800d97fa55d0+incompatible/api/general_test.go (about) 1 // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 // See License.txt for license information. 3 4 package api 5 6 import ( 7 "testing" 8 9 "github.com/mattermost/mattermost-server/model" 10 ) 11 12 func TestGetClientProperties(t *testing.T) { 13 th := Setup().InitBasic() 14 defer th.TearDown() 15 16 if props, err := th.BasicClient.GetClientProperties(); err != nil { 17 t.Fatal(err) 18 } else { 19 if len(props["Version"]) == 0 { 20 t.Fatal() 21 } 22 } 23 } 24 25 func TestLogClient(t *testing.T) { 26 th := Setup().InitBasic() 27 defer th.TearDown() 28 29 if ret, _ := th.BasicClient.LogClient("this is a test"); !ret { 30 t.Fatal("failed to log") 31 } 32 33 enableDeveloper := *th.App.Config().ServiceSettings.EnableDeveloper 34 defer func() { 35 th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableDeveloper = enableDeveloper }) 36 }() 37 th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableDeveloper = false }) 38 39 th.BasicClient.Logout() 40 41 if _, err := th.BasicClient.LogClient("this is a test"); err == nil { 42 t.Fatal("should have failed") 43 } 44 45 th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableDeveloper = true }) 46 47 if ret, _ := th.BasicClient.LogClient("this is a test"); !ret { 48 t.Fatal("failed to log") 49 } 50 } 51 52 func TestGetPing(t *testing.T) { 53 th := Setup().InitBasic() 54 defer th.TearDown() 55 56 if m, err := th.BasicClient.GetPing(); err != nil { 57 t.Fatal(err) 58 } else { 59 if len(m["version"]) == 0 { 60 t.Fatal() 61 } 62 } 63 }