summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2017-02-09 13:39:15 -0800
committerGeorge Goldberg <george@gberg.me>2017-02-09 21:39:15 +0000
commit1359f7f3918befd2463103379d17bd2eb846654d (patch)
treef8fe7cbfd7b8a59da7a655f7ac7bbc9233a70258
parent432dc9239fdd27063adcee944675d066fb35cde6 (diff)
downloadchat-1359f7f3918befd2463103379d17bd2eb846654d.tar.gz
chat-1359f7f3918befd2463103379d17bd2eb846654d.tar.bz2
chat-1359f7f3918befd2463103379d17bd2eb846654d.zip
Adding go vet from hack-a-thon (#5328)
* Adding go vet to the api package * Adding go vet to app package * Adding go vet to manualtesting package * Adding go vet to the model package * Adding go vet to the store dir * Adding go vet to utils package * Adding missing dirs with go files * Fixing up makefile * Fixing up makefile * Removing root dir
-rw-r--r--Makefile34
-rw-r--r--api/auto_constants.go20
-rw-r--r--api/auto_environment.go2
-rw-r--r--api/auto_posts.go8
-rw-r--r--api/auto_users.go2
-rw-r--r--api/command_loadtest.go32
-rw-r--r--app/analytics.go36
-rw-r--r--app/channel.go2
-rw-r--r--app/import_test.go4
-rw-r--r--app/notification.go4
-rw-r--r--app/status.go6
-rw-r--r--app/user.go4
-rw-r--r--manualtesting/manual_testing.go2
-rw-r--r--model/job.go4
-rw-r--r--model/user_test.go8
-rw-r--r--model/utils.go16
-rw-r--r--model/utils_test.go2
-rw-r--r--store/sql_channel_store_test.go20
-rw-r--r--store/sql_status_store_test.go8
-rw-r--r--store/sql_store.go20
-rw-r--r--store/sql_user_store_test.go2
-rw-r--r--utils/mail.go4
22 files changed, 133 insertions, 107 deletions
diff --git a/Makefile b/Makefile
index e47237795..c99767a3a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-.PHONY: build package run stop run-client run-server stop-client stop-server restart restart-server restart-client start-docker clean-dist clean nuke check-style check-client-style check-server-style check-unit-tests test dist setup-mac prepare-enteprise run-client-tests setup-run-client-tests cleanup-run-client-tests test-client build-linux build-osx build-windows internal-test-client
+.PHONY: build package run stop run-client run-server stop-client stop-server restart restart-server restart-client start-docker clean-dist clean nuke check-style check-client-style check-server-style check-unit-tests test dist setup-mac prepare-enteprise run-client-tests setup-run-client-tests cleanup-run-client-tests test-client build-linux build-osx build-windows internal-test-client vet
# For golang 1.5.x compatibility (remove when we don't want to support it anymore)
export GO15VENDOREXPERIMENT=1
@@ -183,7 +183,7 @@ check-client-style:
cd $(BUILD_WEBAPP_DIR) && $(MAKE) check-style
-check-server-style:
+check-server-style: govet
@echo Running GOFMT
$(eval GOFMT_OUTPUT := $(shell gofmt -d -s api/ model/ store/ utils/ manualtesting/ einterfaces/ cmd/platform/ 2>&1))
@echo "$(GOFMT_OUTPUT)"
@@ -467,6 +467,36 @@ nuke: clean clean-docker
setup-mac:
echo $$(boot2docker ip 2> /dev/null) dockerhost | sudo tee -a /etc/hosts
+govet:
+ @echo Running GOVET
+
+ $(GO) vet $(GOFLAGS) ./api || exit 1
+ $(GO) vet $(GOFLAGS) ./api4 || exit 1
+ $(GO) vet $(GOFLAGS) ./app || exit 1
+ $(GO) vet $(GOFLAGS) ./cmd/platform || exit 1
+ $(GO) vet $(GOFLAGS) ./einterfaces || exit 1
+ $(GO) vet $(GOFLAGS) ./manualtesting || exit 1
+ $(GO) vet $(GOFLAGS) ./model || exit 1
+ $(GO) vet $(GOFLAGS) ./model/gitlab || exit 1
+ $(GO) vet $(GOFLAGS) ./store || exit 1
+ $(GO) vet $(GOFLAGS) ./utils || exit 1
+ $(GO) vet $(GOFLAGS) ./web || exit 1
+
+ifeq ($(BUILD_ENTERPRISE_READY),true)
+ $(GO) vet $(GOFLAGS) ./enterprise || exit 1
+ $(GO) vet $(GOFLAGS) ./enterprise/account_migration || exit 1
+ $(GO) vet $(GOFLAGS) ./enterprise/brand || exit 1
+ $(GO) vet $(GOFLAGS) ./enterprise/cluster || exit 1
+ $(GO) vet $(GOFLAGS) ./enterprise/compliance || exit 1
+ $(GO) vet $(GOFLAGS) ./enterprise/emoji || exit 1
+ $(GO) vet $(GOFLAGS) ./enterprise/ldap || exit 1
+ $(GO) vet $(GOFLAGS) ./enterprise/metrics || exit 1
+ $(GO) vet $(GOFLAGS) ./enterprise/mfa || exit 1
+ $(GO) vet $(GOFLAGS) ./enterprise/oauth/google || exit 1
+ $(GO) vet $(GOFLAGS) ./enterprise/oauth/office365 || exit 1
+ $(GO) vet $(GOFLAGS) ./enterprise/saml || exit 1
+endif
+
todo:
@ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime --ignore-dir webapp/non_npm_dependencies/ TODO
@ag --ignore Makefile --ignore-dir vendor --ignore-dir runtime --ignore-dir webapp/non_npm_dependencies/ XXX
diff --git a/api/auto_constants.go b/api/auto_constants.go
index f5d5dab0c..a10ae99f2 100644
--- a/api/auto_constants.go
+++ b/api/auto_constants.go
@@ -22,15 +22,15 @@ const (
)
var (
- TEAM_NAME_LEN = utils.Range{10, 20}
- TEAM_DOMAIN_NAME_LEN = utils.Range{10, 20}
- TEAM_EMAIL_LEN = utils.Range{15, 30}
- USER_NAME_LEN = utils.Range{5, 20}
- USER_EMAIL_LEN = utils.Range{15, 30}
- CHANNEL_DISPLAY_NAME_LEN = utils.Range{10, 20}
- CHANNEL_NAME_LEN = utils.Range{5, 20}
- POST_MESSAGE_LEN = utils.Range{100, 400}
- POST_HASHTAGS_NUM = utils.Range{5, 10}
- POST_MENTIONS_NUM = utils.Range{0, 3}
+ TEAM_NAME_LEN = utils.Range{Begin: 10, End: 20}
+ TEAM_DOMAIN_NAME_LEN = utils.Range{Begin: 10, End: 20}
+ TEAM_EMAIL_LEN = utils.Range{Begin: 15, End: 30}
+ USER_NAME_LEN = utils.Range{Begin: 5, End: 20}
+ USER_EMAIL_LEN = utils.Range{Begin: 15, End: 30}
+ CHANNEL_DISPLAY_NAME_LEN = utils.Range{Begin: 10, End: 20}
+ CHANNEL_NAME_LEN = utils.Range{Begin: 5, End: 20}
+ POST_MESSAGE_LEN = utils.Range{Begin: 100, End: 400}
+ POST_HASHTAGS_NUM = utils.Range{Begin: 5, End: 10}
+ POST_MENTIONS_NUM = utils.Range{Begin: 0, End: 3}
TEST_IMAGE_FILENAMES = []string{"test.png", "testjpg.jpg", "testgif.gif"}
)
diff --git a/api/auto_environment.go b/api/auto_environment.go
index 270b43936..6c7bc2d0a 100644
--- a/api/auto_environment.go
+++ b/api/auto_environment.go
@@ -84,7 +84,7 @@ func CreateTestEnvironmentInTeam(client *model.Client, team *model.Team, rangeCh
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})]
+ user := users[utils.RandIntFromRange(utils.Range{Begin: 0, End: len(users) - 1})]
client.LoginById(user.Id, USER_PASSWORD)
for i, channel := range channels {
postCreator := NewAutoPostCreator(client, channel.Id)
diff --git a/api/auto_posts.go b/api/auto_posts.go
index 6b1207c10..bb20aadae 100644
--- a/api/auto_posts.go
+++ b/api/auto_posts.go
@@ -29,17 +29,17 @@ func NewAutoPostCreator(client *model.Client, channelid string) *AutoPostCreator
client: client,
channelid: channelid,
Fuzzy: false,
- TextLength: utils.Range{100, 200},
+ TextLength: utils.Range{Begin: 100, End: 200},
HasImage: false,
ImageFilenames: TEST_IMAGE_FILENAMES,
Users: []string{},
- Mentions: utils.Range{0, 5},
- Tags: utils.Range{0, 7},
+ Mentions: utils.Range{Begin: 0, End: 5},
+ Tags: utils.Range{Begin: 0, End: 7},
}
}
func (cfg *AutoPostCreator) UploadTestFile() ([]string, bool) {
- filename := cfg.ImageFilenames[utils.RandIntFromRange(utils.Range{0, len(cfg.ImageFilenames) - 1})]
+ filename := cfg.ImageFilenames[utils.RandIntFromRange(utils.Range{Begin: 0, End: len(cfg.ImageFilenames) - 1})]
path := utils.FindDir("web/static/images")
file, err := os.Open(path + "/" + filename)
diff --git a/api/auto_users.go b/api/auto_users.go
index f1f7b483c..d8cd8d3a3 100644
--- a/api/auto_users.go
+++ b/api/auto_users.go
@@ -81,7 +81,7 @@ func (cfg *AutoUserCreator) createRandomUser() (*model.User, bool) {
ruser := result.Data.(*model.User)
- status := &model.Status{ruser.Id, model.STATUS_ONLINE, false, model.GetMillis(), ""}
+ status := &model.Status{UserId: ruser.Id, Status: model.STATUS_ONLINE, Manual: false, LastActivityAt: model.GetMillis(), ActiveChannel: ""}
if result := <-app.Srv.Store.Status().SaveOrUpdate(status); result.Err != nil {
result.Err.Translate(utils.T)
l4g.Error(result.Err.Error())
diff --git a/api/command_loadtest.go b/api/command_loadtest.go
index 3b9ebfe47..dfbbadc3b 100644
--- a/api/command_loadtest.go
+++ b/api/command_loadtest.go
@@ -169,10 +169,10 @@ func (me *LoadTestProvider) SetupCommand(c *Context, channelId string, message s
client.Login(BTEST_USER_EMAIL, BTEST_USER_PASSWORD)
environment, err := CreateTestEnvironmentWithTeams(
client,
- utils.Range{numTeams, numTeams},
- utils.Range{numChannels, numChannels},
- utils.Range{numUsers, numUsers},
- utils.Range{numPosts, numPosts},
+ utils.Range{Begin: numTeams, End: numTeams},
+ utils.Range{Begin: numChannels, End: numChannels},
+ utils.Range{Begin: numUsers, End: numUsers},
+ utils.Range{Begin: numPosts, End: numPosts},
doFuzz)
if err != true {
return &model.CommandResponse{Text: "Failed to create testing environment", ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
@@ -197,9 +197,9 @@ func (me *LoadTestProvider) SetupCommand(c *Context, channelId string, message s
CreateTestEnvironmentInTeam(
client,
team,
- utils.Range{numChannels, numChannels},
- utils.Range{numUsers, numUsers},
- utils.Range{numPosts, numPosts},
+ utils.Range{Begin: numChannels, End: numChannels},
+ utils.Range{Begin: numUsers, End: numUsers},
+ utils.Range{Begin: numPosts, End: numPosts},
doFuzz)
}
@@ -217,7 +217,7 @@ func (me *LoadTestProvider) UsersCommand(c *Context, channelId string, message s
usersr, err := parseRange(cmd, "")
if err == false {
- usersr = utils.Range{2, 5}
+ usersr = utils.Range{Begin: 2, End: 5}
}
var team *model.Team
@@ -247,7 +247,7 @@ func (me *LoadTestProvider) ChannelsCommand(c *Context, channelId string, messag
channelsr, err := parseRange(cmd, "")
if err == false {
- channelsr = utils.Range{2, 5}
+ channelsr = utils.Range{Begin: 2, End: 5}
}
var team *model.Team
@@ -278,14 +278,14 @@ func (me *LoadTestProvider) PostsCommand(c *Context, channelId string, message s
postsr, err := parseRange(cmd, "")
if err == false {
- postsr = utils.Range{20, 30}
+ postsr = utils.Range{Begin: 20, End: 30}
}
tokens := strings.Fields(cmd)
- rimages := utils.Range{0, 0}
+ rimages := utils.Range{Begin: 0, End: 0}
if len(tokens) >= 3 {
if numImages, err := strconv.Atoi(tokens[2]); err == nil {
- rimages = utils.Range{numImages, numImages}
+ rimages = utils.Range{Begin: numImages, End: numImages}
}
}
@@ -415,18 +415,18 @@ func parseRange(command string, cmd string) (utils.Range, bool) {
begin, err1 = strconv.Atoi(tokens[0])
end = begin
if err1 != nil {
- return utils.Range{0, 0}, false
+ return utils.Range{Begin: 0, End: 0}, false
}
case len(tokens) >= 2:
begin, err1 = strconv.Atoi(tokens[0])
end, err2 = strconv.Atoi(tokens[1])
if err1 != nil || err2 != nil {
- return utils.Range{0, 0}, false
+ return utils.Range{Begin: 0, End: 0}, false
}
default:
- return utils.Range{0, 0}, false
+ return utils.Range{Begin: 0, End: 0}, false
}
- return utils.Range{begin, end}, true
+ return utils.Range{Begin: begin, End: end}, true
}
func contains(items []string, token string) bool {
diff --git a/app/analytics.go b/app/analytics.go
index 891c0dfae..f1146327f 100644
--- a/app/analytics.go
+++ b/app/analytics.go
@@ -31,16 +31,16 @@ func GetAnalytics(name string, teamId string) (model.AnalyticsRows, *model.AppEr
if name == "standard" {
var rows model.AnalyticsRows = make([]*model.AnalyticsRow, 10)
- rows[0] = &model.AnalyticsRow{"channel_open_count", 0}
- rows[1] = &model.AnalyticsRow{"channel_private_count", 0}
- rows[2] = &model.AnalyticsRow{"post_count", 0}
- rows[3] = &model.AnalyticsRow{"unique_user_count", 0}
- rows[4] = &model.AnalyticsRow{"team_count", 0}
- rows[5] = &model.AnalyticsRow{"total_websocket_connections", 0}
- rows[6] = &model.AnalyticsRow{"total_master_db_connections", 0}
- rows[7] = &model.AnalyticsRow{"total_read_db_connections", 0}
- rows[8] = &model.AnalyticsRow{"daily_active_users", 0}
- rows[9] = &model.AnalyticsRow{"monthly_active_users", 0}
+ rows[0] = &model.AnalyticsRow{Name: "channel_open_count", Value: 0}
+ rows[1] = &model.AnalyticsRow{Name: "channel_private_count", Value: 0}
+ rows[2] = &model.AnalyticsRow{Name: "post_count", Value: 0}
+ rows[3] = &model.AnalyticsRow{Name: "unique_user_count", Value: 0}
+ rows[4] = &model.AnalyticsRow{Name: "team_count", Value: 0}
+ rows[5] = &model.AnalyticsRow{Name: "total_websocket_connections", Value: 0}
+ rows[6] = &model.AnalyticsRow{Name: "total_master_db_connections", Value: 0}
+ rows[7] = &model.AnalyticsRow{Name: "total_read_db_connections", Value: 0}
+ rows[8] = &model.AnalyticsRow{Name: "daily_active_users", Value: 0}
+ rows[9] = &model.AnalyticsRow{Name: "monthly_active_users", Value: 0}
openChan := Srv.Store.Channel().AnalyticsTypeCount(teamId, model.CHANNEL_OPEN)
privateChan := Srv.Store.Channel().AnalyticsTypeCount(teamId, model.CHANNEL_PRIVATE)
@@ -139,7 +139,7 @@ func GetAnalytics(name string, teamId string) (model.AnalyticsRows, *model.AppEr
return rows, nil
} else if name == "post_counts_day" {
if skipIntensiveQueries {
- rows := model.AnalyticsRows{&model.AnalyticsRow{"", -1}}
+ rows := model.AnalyticsRows{&model.AnalyticsRow{Name: "", Value: -1}}
return rows, nil
}
@@ -150,7 +150,7 @@ func GetAnalytics(name string, teamId string) (model.AnalyticsRows, *model.AppEr
}
} else if name == "user_counts_with_posts_day" {
if skipIntensiveQueries {
- rows := model.AnalyticsRows{&model.AnalyticsRow{"", -1}}
+ rows := model.AnalyticsRows{&model.AnalyticsRow{Name: "", Value: -1}}
return rows, nil
}
@@ -161,12 +161,12 @@ func GetAnalytics(name string, teamId string) (model.AnalyticsRows, *model.AppEr
}
} else if name == "extra_counts" {
var rows model.AnalyticsRows = make([]*model.AnalyticsRow, 6)
- rows[0] = &model.AnalyticsRow{"file_post_count", 0}
- rows[1] = &model.AnalyticsRow{"hashtag_post_count", 0}
- rows[2] = &model.AnalyticsRow{"incoming_webhook_count", 0}
- rows[3] = &model.AnalyticsRow{"outgoing_webhook_count", 0}
- rows[4] = &model.AnalyticsRow{"command_count", 0}
- rows[5] = &model.AnalyticsRow{"session_count", 0}
+ rows[0] = &model.AnalyticsRow{Name: "file_post_count", Value: 0}
+ rows[1] = &model.AnalyticsRow{Name: "hashtag_post_count", Value: 0}
+ rows[2] = &model.AnalyticsRow{Name: "incoming_webhook_count", Value: 0}
+ rows[3] = &model.AnalyticsRow{Name: "outgoing_webhook_count", Value: 0}
+ rows[4] = &model.AnalyticsRow{Name: "command_count", Value: 0}
+ rows[5] = &model.AnalyticsRow{Name: "session_count", Value: 0}
iHookChan := Srv.Store.Webhook().AnalyticsIncomingCount(teamId)
oHookChan := Srv.Store.Webhook().AnalyticsOutgoingCount(teamId)
diff --git a/app/channel.go b/app/channel.go
index ccacc2ca6..fcd4e166d 100644
--- a/app/channel.go
+++ b/app/channel.go
@@ -805,7 +805,7 @@ func GetNumberOfChannelsOnTeam(teamId string) (int, *model.AppError) {
func SetActiveChannel(userId string, channelId string) *model.AppError {
status, err := GetStatus(userId)
if err != nil {
- status = &model.Status{userId, model.STATUS_ONLINE, false, model.GetMillis(), channelId}
+ status = &model.Status{UserId: userId, Status: model.STATUS_ONLINE, Manual: false, LastActivityAt: model.GetMillis(), ActiveChannel: channelId}
} else {
status.ActiveChannel = channelId
if !status.Manual {
diff --git a/app/import_test.go b/app/import_test.go
index b57fb0217..e163ddc45 100644
--- a/app/import_test.go
+++ b/app/import_test.go
@@ -513,7 +513,7 @@ func TestImportImportTeam(t *testing.T) {
// Check that one more team is in the DB.
if r := <-Srv.Store.Team().AnalyticsTeamCount(); r.Err == nil {
if r.Data.(int64)-1 != teamsCount {
- t.Fatalf("Team did not get saved in apply run mode.", r.Data.(int64), teamsCount)
+ t.Fatalf("Team did not get saved in apply run mode. analytics=%v teamcount=%v", r.Data.(int64), teamsCount)
}
} else {
t.Fatalf("Failed to get team count.")
@@ -542,7 +542,7 @@ func TestImportImportTeam(t *testing.T) {
if r := <-Srv.Store.Team().AnalyticsTeamCount(); r.Err == nil {
if r.Data.(int64)-1 != teamsCount {
- t.Fatalf("Team alterations did not get saved in apply run mode.", r.Data.(int64), teamsCount)
+ t.Fatalf("Team alterations did not get saved in apply run mode. analytics=%v teamcount=%v", r.Data.(int64), teamsCount)
}
} else {
t.Fatalf("Failed to get team count.")
diff --git a/app/notification.go b/app/notification.go
index 1550c0393..f2b454b50 100644
--- a/app/notification.go
+++ b/app/notification.go
@@ -241,7 +241,7 @@ func SendNotifications(post *model.Post, team *model.Team, channel *model.Channe
var status *model.Status
var err *model.AppError
if status, err = GetStatus(id); err != nil {
- status = &model.Status{id, model.STATUS_OFFLINE, false, 0, ""}
+ status = &model.Status{UserId: id, Status: model.STATUS_OFFLINE, Manual: false, LastActivityAt: 0, ActiveChannel: ""}
}
if DoesStatusAllowPushNotification(profileMap[id], status, post.ChannelId) {
@@ -254,7 +254,7 @@ func SendNotifications(post *model.Post, team *model.Team, channel *model.Channe
var status *model.Status
var err *model.AppError
if status, err = GetStatus(id); err != nil {
- status = &model.Status{id, model.STATUS_OFFLINE, false, 0, ""}
+ status = &model.Status{UserId: id, Status: model.STATUS_OFFLINE, Manual: false, LastActivityAt: 0, ActiveChannel: ""}
}
if DoesStatusAllowPushNotification(profileMap[id], status, post.ChannelId) {
diff --git a/app/status.go b/app/status.go
index 98cdb0dc0..bef17165f 100644
--- a/app/status.go
+++ b/app/status.go
@@ -100,7 +100,7 @@ func SetStatusOnline(userId string, sessionId string, manual bool) {
var err *model.AppError
if status, err = GetStatus(userId); err != nil {
- status = &model.Status{userId, model.STATUS_ONLINE, false, model.GetMillis(), ""}
+ status = &model.Status{UserId: userId, Status: model.STATUS_ONLINE, Manual: false, LastActivityAt: model.GetMillis(), ActiveChannel: ""}
broadcast = true
} else {
if status.Manual && !manual {
@@ -157,7 +157,7 @@ func SetStatusOffline(userId string, manual bool) {
return // manually set status always overrides non-manual one
}
- status = &model.Status{userId, model.STATUS_OFFLINE, manual, model.GetMillis(), ""}
+ status = &model.Status{UserId: userId, Status: model.STATUS_OFFLINE, Manual: manual, LastActivityAt: model.GetMillis(), ActiveChannel: ""}
AddStatusCache(status)
@@ -175,7 +175,7 @@ func SetStatusAwayIfNeeded(userId string, manual bool) {
status, err := GetStatus(userId)
if err != nil {
- status = &model.Status{userId, model.STATUS_OFFLINE, manual, 0, ""}
+ status = &model.Status{UserId: userId, Status: model.STATUS_OFFLINE, Manual: manual, LastActivityAt: 0, ActiveChannel: ""}
}
if !manual && status.Manual {
diff --git a/app/user.go b/app/user.go
index 94ab89bee..1d6fa9e34 100644
--- a/app/user.go
+++ b/app/user.go
@@ -307,11 +307,9 @@ func IsUsernameTaken(name string) bool {
if result := <-Srv.Store.User().GetByUsername(name); result.Err != nil {
return false
- } else {
- return true
}
- return false
+ return true
}
func GetUser(userId string) (*model.User, *model.AppError) {
diff --git a/manualtesting/manual_testing.go b/manualtesting/manual_testing.go
index 30249f995..33192ff5e 100644
--- a/manualtesting/manual_testing.go
+++ b/manualtesting/manual_testing.go
@@ -67,7 +67,7 @@ func manualTest(c *api.Context, w http.ResponseWriter, r *http.Request) {
// Create team for testing
team := &model.Team{
DisplayName: teamDisplayName[0],
- Name: utils.RandomName(utils.Range{20, 20}, utils.LOWERCASE),
+ Name: utils.RandomName(utils.Range{Begin: 20, End: 20}, utils.LOWERCASE),
Email: "success+" + model.NewId() + "simulator.amazonses.com",
Type: model.TEAM_OPEN,
}
diff --git a/model/job.go b/model/job.go
index 229d5efd3..09d74aa09 100644
--- a/model/job.go
+++ b/model/job.go
@@ -14,8 +14,8 @@ type ScheduledTask struct {
Name string `json:"name"`
Interval time.Duration `json:"interval"`
Recurring bool `json:"recurring"`
- function TaskFunc `json:",omitempty"`
- timer *time.Timer `json:",omitempty"`
+ function TaskFunc
+ timer *time.Timer
}
var tasks = make(map[string]*ScheduledTask)
diff --git a/model/user_test.go b/model/user_test.go
index 15b1aae6f..4f5c16614 100644
--- a/model/user_test.go
+++ b/model/user_test.go
@@ -46,25 +46,25 @@ func TestUserUpdateMentionKeysFromUsername(t *testing.T) {
user.SetDefaultNotifications()
if user.NotifyProps["mention_keys"] != "user,@user" {
- t.Fatal("default mention keys are invalid: %v", user.NotifyProps["mention_keys"])
+ t.Fatalf("default mention keys are invalid: %v", user.NotifyProps["mention_keys"])
}
user.Username = "person"
user.UpdateMentionKeysFromUsername("user")
if user.NotifyProps["mention_keys"] != "person,@person" {
- t.Fatal("mention keys are invalid after changing username: %v", user.NotifyProps["mention_keys"])
+ t.Fatalf("mention keys are invalid after changing username: %v", user.NotifyProps["mention_keys"])
}
user.NotifyProps["mention_keys"] += ",mention"
user.UpdateMentionKeysFromUsername("person")
if user.NotifyProps["mention_keys"] != "person,@person,mention" {
- t.Fatal("mention keys are invalid after adding extra mention keyword: %v", user.NotifyProps["mention_keys"])
+ t.Fatalf("mention keys are invalid after adding extra mention keyword: %v", user.NotifyProps["mention_keys"])
}
user.Username = "user"
user.UpdateMentionKeysFromUsername("person")
if user.NotifyProps["mention_keys"] != "user,@user,mention" {
- t.Fatal("mention keys are invalid after changing username with extra mention keyword: %v", user.NotifyProps["mention_keys"])
+ t.Fatalf("mention keys are invalid after changing username with extra mention keyword: %v", user.NotifyProps["mention_keys"])
}
}
diff --git a/model/utils.go b/model/utils.go
index 05143b20d..9ecc19595 100644
--- a/model/utils.go
+++ b/model/utils.go
@@ -34,14 +34,14 @@ type StringArray []string
type EncryptStringMap map[string]string
type AppError struct {
- Id string `json:"id"`
- Message string `json:"message"` // Message to be display to the end user without debugging information
- DetailedError string `json:"detailed_error"` // Internal error string to help the developer
- RequestId string `json:"request_id,omitempty"` // The RequestId that's also set in the header
- StatusCode int `json:"status_code,omitempty"` // The http status code
- Where string `json:"-"` // The function where it happened in the form of Struct.Func
- IsOAuth bool `json:"is_oauth,omitempty"` // Whether the error is OAuth specific
- params map[string]interface{} `json:"-"`
+ Id string `json:"id"`
+ Message string `json:"message"` // Message to be display to the end user without debugging information
+ DetailedError string `json:"detailed_error"` // Internal error string to help the developer
+ RequestId string `json:"request_id,omitempty"` // The RequestId that's also set in the header
+ StatusCode int `json:"status_code,omitempty"` // The http status code
+ Where string `json:"-"` // The function where it happened in the form of Struct.Func
+ IsOAuth bool `json:"is_oauth,omitempty"` // Whether the error is OAuth specific
+ params map[string]interface{}
}
func (er *AppError) Error() string {
diff --git a/model/utils_test.go b/model/utils_test.go
index dbe1e59be..7c6100a04 100644
--- a/model/utils_test.go
+++ b/model/utils_test.go
@@ -34,7 +34,7 @@ func TestAppError(t *testing.T) {
t.Fatal()
}
- err.Error()
+ t.Log(err.Error())
}
func TestAppErrorJunk(t *testing.T) {
diff --git a/store/sql_channel_store_test.go b/store/sql_channel_store_test.go
index 03fc50857..002f9cb66 100644
--- a/store/sql_channel_store_test.go
+++ b/store/sql_channel_store_test.go
@@ -1062,9 +1062,9 @@ func TestGetMemberCount(t *testing.T) {
Must(store.Channel().SaveMember(&m1))
if result := <-store.Channel().GetMemberCount(c1.Id, false); result.Err != nil {
- t.Fatal("failed to get member count: %v", result.Err)
+ t.Fatalf("failed to get member count: %v", result.Err)
} else if result.Data.(int64) != 1 {
- t.Fatal("got incorrect member count %v", result.Data)
+ t.Fatalf("got incorrect member count %v", result.Data)
}
u2 := model.User{
@@ -1082,9 +1082,9 @@ func TestGetMemberCount(t *testing.T) {
Must(store.Channel().SaveMember(&m2))
if result := <-store.Channel().GetMemberCount(c1.Id, false); result.Err != nil {
- t.Fatal("failed to get member count: %v", result.Err)
+ t.Fatalf("failed to get member count: %v", result.Err)
} else if result.Data.(int64) != 2 {
- t.Fatal("got incorrect member count %v", result.Data)
+ t.Fatalf("got incorrect member count %v", result.Data)
}
// make sure members of other channels aren't counted
@@ -1103,9 +1103,9 @@ func TestGetMemberCount(t *testing.T) {
Must(store.Channel().SaveMember(&m3))
if result := <-store.Channel().GetMemberCount(c1.Id, false); result.Err != nil {
- t.Fatal("failed to get member count: %v", result.Err)
+ t.Fatalf("failed to get member count: %v", result.Err)
} else if result.Data.(int64) != 2 {
- t.Fatal("got incorrect member count %v", result.Data)
+ t.Fatalf("got incorrect member count %v", result.Data)
}
// make sure inactive users aren't counted
@@ -1124,9 +1124,9 @@ func TestGetMemberCount(t *testing.T) {
Must(store.Channel().SaveMember(&m4))
if result := <-store.Channel().GetMemberCount(c1.Id, false); result.Err != nil {
- t.Fatal("failed to get member count: %v", result.Err)
+ t.Fatalf("failed to get member count: %v", result.Err)
} else if result.Data.(int64) != 2 {
- t.Fatal("got incorrect member count %v", result.Data)
+ t.Fatalf("got incorrect member count %v", result.Data)
}
}
@@ -1169,14 +1169,14 @@ func TestUpdateExtrasByUser(t *testing.T) {
Must(store.User().Update(u1, true))
if result := <-store.Channel().ExtraUpdateByUser(u1.Id, u1.DeleteAt); result.Err != nil {
- t.Fatal("failed to update extras by user: %v", result.Err)
+ t.Fatalf("failed to update extras by user: %v", result.Err)
}
u1.DeleteAt = 0
Must(store.User().Update(u1, true))
if result := <-store.Channel().ExtraUpdateByUser(u1.Id, u1.DeleteAt); result.Err != nil {
- t.Fatal("failed to update extras by user: %v", result.Err)
+ t.Fatalf("failed to update extras by user: %v", result.Err)
}
}
diff --git a/store/sql_status_store_test.go b/store/sql_status_store_test.go
index dce973850..47561cda0 100644
--- a/store/sql_status_store_test.go
+++ b/store/sql_status_store_test.go
@@ -12,7 +12,7 @@ import (
func TestSqlStatusStore(t *testing.T) {
Setup()
- status := &model.Status{model.NewId(), model.STATUS_ONLINE, false, 0, ""}
+ status := &model.Status{UserId: model.NewId(), Status: model.STATUS_ONLINE, Manual: false, LastActivityAt: 0, ActiveChannel: ""}
if err := (<-store.Status().SaveOrUpdate(status)).Err; err != nil {
t.Fatal(err)
@@ -28,12 +28,12 @@ func TestSqlStatusStore(t *testing.T) {
t.Fatal(err)
}
- status2 := &model.Status{model.NewId(), model.STATUS_AWAY, false, 0, ""}
+ status2 := &model.Status{UserId: model.NewId(), Status: model.STATUS_AWAY, Manual: false, LastActivityAt: 0, ActiveChannel: ""}
if err := (<-store.Status().SaveOrUpdate(status2)).Err; err != nil {
t.Fatal(err)
}
- status3 := &model.Status{model.NewId(), model.STATUS_OFFLINE, false, 0, ""}
+ status3 := &model.Status{UserId: model.NewId(), Status: model.STATUS_OFFLINE, Manual: false, LastActivityAt: 0, ActiveChannel: ""}
if err := (<-store.Status().SaveOrUpdate(status3)).Err; err != nil {
t.Fatal(err)
}
@@ -90,7 +90,7 @@ func TestSqlStatusStore(t *testing.T) {
func TestActiveUserCount(t *testing.T) {
Setup()
- status := &model.Status{model.NewId(), model.STATUS_ONLINE, false, model.GetMillis(), ""}
+ status := &model.Status{UserId: model.NewId(), Status: model.STATUS_ONLINE, Manual: false, LastActivityAt: model.GetMillis(), ActiveChannel: ""}
Must(store.Status().SaveOrUpdate(status))
if result := <-store.Status().GetTotalActiveUsersCount(); result.Err != nil {
diff --git a/store/sql_store.go b/store/sql_store.go
index 214bce720..03867cc44 100644
--- a/store/sql_store.go
+++ b/store/sql_store.go
@@ -220,16 +220,14 @@ func (ss *SqlStore) TotalReadDbConnections() int {
if len(utils.Cfg.SqlSettings.DataSourceReplicas) == 0 {
return 0
- } else {
- count := 0
- for _, db := range ss.replicas {
- count = count + db.Db.Stats().OpenConnections
- }
+ }
- return count
+ count := 0
+ for _, db := range ss.replicas {
+ count = count + db.Db.Stats().OpenConnections
}
- return 0
+ return count
}
func (ss *SqlStore) GetCurrentSchemaVersion() string {
@@ -722,7 +720,7 @@ func (me mattermConverter) FromDb(target interface{}) (gorp.CustomScanner, bool)
b := []byte(*s)
return json.Unmarshal(b, target)
}
- return gorp.CustomScanner{new(string), target, binder}, true
+ return gorp.CustomScanner{Holder: new(string), Target: target, Binder: binder}, true
case *model.StringArray:
binder := func(holder, target interface{}) error {
s, ok := holder.(*string)
@@ -732,7 +730,7 @@ func (me mattermConverter) FromDb(target interface{}) (gorp.CustomScanner, bool)
b := []byte(*s)
return json.Unmarshal(b, target)
}
- return gorp.CustomScanner{new(string), target, binder}, true
+ return gorp.CustomScanner{Holder: new(string), Target: target, Binder: binder}, true
case *model.EncryptStringMap:
binder := func(holder, target interface{}) error {
s, ok := holder.(*string)
@@ -748,7 +746,7 @@ func (me mattermConverter) FromDb(target interface{}) (gorp.CustomScanner, bool)
b := []byte(ue)
return json.Unmarshal(b, target)
}
- return gorp.CustomScanner{new(string), target, binder}, true
+ return gorp.CustomScanner{Holder: new(string), Target: target, Binder: binder}, true
case *model.StringInterface:
binder := func(holder, target interface{}) error {
s, ok := holder.(*string)
@@ -758,7 +756,7 @@ func (me mattermConverter) FromDb(target interface{}) (gorp.CustomScanner, bool)
b := []byte(*s)
return json.Unmarshal(b, target)
}
- return gorp.CustomScanner{new(string), target, binder}, true
+ return gorp.CustomScanner{Holder: new(string), Target: target, Binder: binder}, true
}
return gorp.CustomScanner{}, false
diff --git a/store/sql_user_store_test.go b/store/sql_user_store_test.go
index 95be3e258..f7236659b 100644
--- a/store/sql_user_store_test.go
+++ b/store/sql_user_store_test.go
@@ -1103,7 +1103,7 @@ func TestUserStoreGetRecentlyActiveUsersForTeam(t *testing.T) {
u1 := &model.User{}
u1.Email = model.NewId()
Must(store.User().Save(u1))
- Must(store.Status().SaveOrUpdate(&model.Status{u1.Id, model.STATUS_ONLINE, false, model.GetMillis(), ""}))
+ Must(store.Status().SaveOrUpdate(&model.Status{UserId: u1.Id, Status: model.STATUS_ONLINE, Manual: false, LastActivityAt: model.GetMillis(), ActiveChannel: ""}))
tid := model.NewId()
Must(store.Team().SaveMember(&model.TeamMember{TeamId: tid, UserId: u1.Id}))
diff --git a/utils/mail.go b/utils/mail.go
index 6a348e52e..7e62c2c54 100644
--- a/utils/mail.go
+++ b/utils/mail.go
@@ -104,8 +104,8 @@ func SendMailUsingConfig(to, subject, body string, config *model.Config) *model.
l4g.Debug(T("utils.mail.send_mail.sending.debug"), to, subject)
- fromMail := mail.Address{config.EmailSettings.FeedbackName, config.EmailSettings.FeedbackEmail}
- toMail := mail.Address{"", to}
+ fromMail := mail.Address{Name: config.EmailSettings.FeedbackName, Address: config.EmailSettings.FeedbackEmail}
+ toMail := mail.Address{Name: "", Address: to}
headers := make(map[string]string)
headers["From"] = fromMail.String()