summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
Diffstat (limited to 'store')
-rw-r--r--store/sql_preference_store.go2
-rw-r--r--store/sql_store.go22
-rw-r--r--store/sql_store_test.go7
-rw-r--r--store/store.go1
4 files changed, 24 insertions, 8 deletions
diff --git a/store/sql_preference_store.go b/store/sql_preference_store.go
index 46cef38b1..dbbe20119 100644
--- a/store/sql_preference_store.go
+++ b/store/sql_preference_store.go
@@ -43,7 +43,7 @@ func (s SqlPreferenceStore) Save(preferences *model.Preferences) StoreChannel {
result := StoreResult{}
// wrap in a transaction so that if one fails, everything fails
- transaction, err := s.GetReplica().Begin()
+ transaction, err := s.GetMaster().Begin()
if err != nil {
result.Err = model.NewAppError("SqlPreferenceStore.Save", "Unable to open transaction to save preferences", err.Error())
} else {
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()
}