From de717aef56dfaa0b9b676ce82d4b9d7abdb12428 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Thu, 15 Oct 2015 11:16:26 -0700 Subject: Marking when user ran the unit tests --- store/sql_store.go | 22 +++++++++++++++++----- store/sql_store_test.go | 7 +++++-- store/store.go | 1 + 3 files changed, 23 insertions(+), 7 deletions(-) (limited to 'store') diff --git a/store/sql_store.go b/store/sql_store.go index 4b055e455..692ac2664 100644 --- a/store/sql_store.go +++ b/store/sql_store.go @@ -16,17 +16,18 @@ import ( "encoding/json" "errors" "fmt" - "github.com/go-gorp/gorp" - _ "github.com/go-sql-driver/mysql" - _ "github.com/lib/pq" - "github.com/mattermost/platform/model" - "github.com/mattermost/platform/utils" "io" sqltrace "log" "math/rand" "os" "strings" "time" + + "github.com/go-gorp/gorp" + _ "github.com/go-sql-driver/mysql" + _ "github.com/lib/pq" + "github.com/mattermost/platform/model" + "github.com/mattermost/platform/utils" ) type SqlStore struct { @@ -179,6 +180,17 @@ func (ss SqlStore) GetCurrentSchemaVersion() string { return version } +func (ss SqlStore) MarkSystemRanUnitTests() { + if result := <-ss.System().Get(); result.Err == nil { + props := result.Data.(model.StringMap) + unitTests := props[model.SYSTEM_RAN_UNIT_TESTS] + if len(unitTests) == 0 { + systemTests := &model.System{Name: model.SYSTEM_RAN_UNIT_TESTS, Value: "1"} + <-ss.System().Save(systemTests) + } + } +} + func (ss SqlStore) DoesTableExist(tableName string) bool { if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES { count, err := ss.GetMaster().SelectInt( diff --git a/store/sql_store_test.go b/store/sql_store_test.go index a9e25cb33..1e04b676c 100644 --- a/store/sql_store_test.go +++ b/store/sql_store_test.go @@ -4,10 +4,11 @@ package store import ( - "github.com/mattermost/platform/model" - "github.com/mattermost/platform/utils" "strings" "testing" + + "github.com/mattermost/platform/model" + "github.com/mattermost/platform/utils" ) var store Store @@ -16,6 +17,8 @@ func Setup() { if store == nil { utils.LoadConfig("config.json") store = NewSqlStore() + + store.MarkSystemRanUnitTests() } } diff --git a/store/store.go b/store/store.go index 6e1614ccb..b436a5c40 100644 --- a/store/store.go +++ b/store/store.go @@ -38,6 +38,7 @@ type Store interface { System() SystemStore Webhook() WebhookStore Preference() PreferenceStore + MarkSystemRanUnitTests() Close() } -- cgit v1.2.3-1-g7c22