summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
Diffstat (limited to 'store')
-rw-r--r--store/sql_store.go22
-rw-r--r--store/sql_store_test.go7
-rw-r--r--store/store.go1
3 files changed, 23 insertions, 7 deletions
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()
}