From cf7a05f80f68b5b1c8bcc0089679dd497cec2506 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Sun, 14 Jun 2015 23:53:32 -0800 Subject: first commit --- api/api_test.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 api/api_test.go (limited to 'api/api_test.go') diff --git a/api/api_test.go b/api/api_test.go new file mode 100644 index 000000000..ffa951f6d --- /dev/null +++ b/api/api_test.go @@ -0,0 +1,42 @@ +// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. +// See License.txt for license information. + +package api + +import ( + "github.com/mattermost/platform/model" + "github.com/mattermost/platform/utils" +) + +var Client *model.Client + +func Setup() { + if Srv == nil { + utils.LoadConfig("config.json") + NewServer() + StartServer() + InitApi() + Client = model.NewClient("http://localhost:" + utils.Cfg.ServiceSettings.Port + "/api/v1") + } +} + +func SetupBenchmark() (*model.Team, *model.User, *model.Channel) { + Setup() + + team := &model.Team{Name: "Benchmark Team", Domain: "z-z-" + model.NewId() + "a", Email: "benchmark@nowhere.com", Type: model.TEAM_OPEN} + team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) + user := &model.User{TeamId: team.Id, Email: model.NewId() + "benchmark@test.com", FullName: "Mr. Benchmarker", Password: "pwd"} + user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) + Srv.Store.User().VerifyEmail(user.Id) + Client.LoginByEmail(team.Domain, user.Email, "pwd") + channel := &model.Channel{DisplayName: "Benchmark Channel", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team.Id} + channel = Client.Must(Client.CreateChannel(channel)).Data.(*model.Channel) + + return team, user, channel +} + +func TearDown() { + if Srv != nil { + StopServer() + } +} -- cgit v1.2.3-1-g7c22