summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
Diffstat (limited to 'store')
-rw-r--r--store/sql_system_store.go21
-rw-r--r--store/sql_system_store_test.go6
-rw-r--r--store/store.go1
3 files changed, 28 insertions, 0 deletions
diff --git a/store/sql_system_store.go b/store/sql_system_store.go
index f8da06cec..a2b4f6396 100644
--- a/store/sql_system_store.go
+++ b/store/sql_system_store.go
@@ -114,3 +114,24 @@ func (s SqlSystemStore) Get() StoreChannel {
return storeChannel
}
+
+func (s SqlSystemStore) GetByName(name string) StoreChannel {
+
+ storeChannel := make(StoreChannel)
+
+ go func() {
+ result := StoreResult{}
+
+ var system model.System
+ if err := s.GetReplica().SelectOne(&system, "SELECT * FROM Systems WHERE Name = :Name", map[string]interface{}{"Name": name}); err != nil {
+ result.Err = model.NewLocAppError("SqlSystemStore.GetByName", "store.sql_system.get_by_name.app_error", nil, "")
+ }
+
+ result.Data = &system
+
+ storeChannel <- result
+ close(storeChannel)
+ }()
+
+ return storeChannel
+}
diff --git a/store/sql_system_store_test.go b/store/sql_system_store_test.go
index ce149e97a..74e2876ad 100644
--- a/store/sql_system_store_test.go
+++ b/store/sql_system_store_test.go
@@ -30,6 +30,12 @@ func TestSqlSystemStore(t *testing.T) {
if systems2[system.Name] != system.Value {
t.Fatal()
}
+
+ result3 := <-store.System().GetByName(system.Name)
+ rsystem := result3.Data.(*model.System)
+ if rsystem.Value != system.Value {
+ t.Fatal()
+ }
}
func TestSqlSystemStoreSaveOrUpdate(t *testing.T) {
diff --git a/store/store.go b/store/store.go
index 323595ffb..4a4fa1481 100644
--- a/store/store.go
+++ b/store/store.go
@@ -184,6 +184,7 @@ type SystemStore interface {
SaveOrUpdate(system *model.System) StoreChannel
Update(system *model.System) StoreChannel
Get() StoreChannel
+ GetByName(name string) StoreChannel
}
type WebhookStore interface {