diff options
author | Pat Lathem <patl@codero.com> | 2015-10-30 12:55:48 -0500 |
---|---|---|
committer | Pat Lathem <patl@codero.com> | 2015-10-30 12:55:48 -0500 |
commit | 42d3694e4bf59c4b71f89f9c02938a23c9bbd84d (patch) | |
tree | ebde1b1f7c2fca81c6a6070bee54b01bfb8040d3 /api/auto_enviroment.go | |
parent | 7d60d96c91effba05922f26ba8671636fc184e16 (diff) | |
download | chat-42d3694e4bf59c4b71f89f9c02938a23c9bbd84d.tar.gz chat-42d3694e4bf59c4b71f89f9c02938a23c9bbd84d.tar.bz2 chat-42d3694e4bf59c4b71f89f9c02938a23c9bbd84d.zip |
Go fmt and rename file with 'enviroment' in filename
Diffstat (limited to 'api/auto_enviroment.go')
-rw-r--r-- | api/auto_enviroment.go | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/api/auto_enviroment.go b/api/auto_enviroment.go deleted file mode 100644 index 28026f361..000000000 --- a/api/auto_enviroment.go +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -package api - -import ( - "github.com/mattermost/platform/model" - "github.com/mattermost/platform/utils" - "math/rand" - "time" -) - -type TestEnvironment struct { - Teams []*model.Team - Environments []TeamEnvironment -} - -func CreateTestEnvironmentWithTeams(client *model.Client, rangeTeams utils.Range, rangeChannels utils.Range, rangeUsers utils.Range, rangePosts utils.Range, fuzzy bool) (TestEnvironment, bool) { - rand.Seed(time.Now().UTC().UnixNano()) - - teamCreator := NewAutoTeamCreator(client) - teamCreator.Fuzzy = fuzzy - teams, err := teamCreator.CreateTestTeams(rangeTeams) - if err != true { - return TestEnvironment{}, false - } - - environment := TestEnvironment{teams, make([]TeamEnvironment, len(teams))} - - for i, team := range teams { - userCreator := NewAutoUserCreator(client, team.Id) - userCreator.Fuzzy = fuzzy - randomUser, err := userCreator.createRandomUser() - if err != true { - return TestEnvironment{}, false - } - client.LoginById(randomUser.Id, USER_PASSWORD) - teamEnvironment, err := CreateTestEnvironmentInTeam(client, team.Id, rangeChannels, rangeUsers, rangePosts, fuzzy) - if err != true { - return TestEnvironment{}, false - } - environment.Environments[i] = teamEnvironment - } - - return environment, true -} - -func CreateTestEnvironmentInTeam(client *model.Client, teamID string, rangeChannels utils.Range, rangeUsers utils.Range, rangePosts utils.Range, fuzzy bool) (TeamEnvironment, bool) { - rand.Seed(time.Now().UTC().UnixNano()) - - // We need to create at least one user - if rangeUsers.Begin <= 0 { - rangeUsers.Begin = 1 - } - - userCreator := NewAutoUserCreator(client, teamID) - userCreator.Fuzzy = fuzzy - users, err := userCreator.CreateTestUsers(rangeUsers) - if err != true { - return TeamEnvironment{}, false - } - usernames := make([]string, len(users)) - for i, user := range users { - usernames[i] = user.Username - } - - channelCreator := NewAutoChannelCreator(client, teamID) - channelCreator.Fuzzy = fuzzy - channels, err := channelCreator.CreateTestChannels(rangeChannels) - - // Have every user join every channel - for _, user := range users { - for _, channel := range channels { - client.LoginById(user.Id, USER_PASSWORD) - client.JoinChannel(channel.Id) - } - } - - if err != true { - return TeamEnvironment{}, false - } - numPosts := utils.RandIntFromRange(rangePosts) - numImages := utils.RandIntFromRange(rangePosts) / 4 - for j := 0; j < numPosts; j++ { - user := users[utils.RandIntFromRange(utils.Range{0, len(users) - 1})] - client.LoginById(user.Id, USER_PASSWORD) - for i, channel := range channels { - postCreator := NewAutoPostCreator(client, channel.Id) - postCreator.HasImage = i < numImages - postCreator.Users = usernames - postCreator.Fuzzy = fuzzy - postCreator.CreateRandomPost() - } - } - - return TeamEnvironment{users, channels}, true -} |