summaryrefslogtreecommitdiffstats
path: root/store/sqlstore/license_store_test.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-09-25 09:11:25 -0500
committerJoram Wilander <jwawilander@gmail.com>2017-09-25 10:11:25 -0400
commit49fe5fbf3db56fc466b8997b182ee135d7a4365d (patch)
tree1252fea09aa3ce899e2e8edb1fb7b42900f50bca /store/sqlstore/license_store_test.go
parentb2c5b97601b61f5748b46e4e386134203111ebb0 (diff)
downloadchat-49fe5fbf3db56fc466b8997b182ee135d7a4365d.tar.gz
chat-49fe5fbf3db56fc466b8997b182ee135d7a4365d.tar.bz2
chat-49fe5fbf3db56fc466b8997b182ee135d7a4365d.zip
Move sql store code into store/sqlstore package (#7502)
* move sql store code into store/sqlstore package * move non-sql constants back up to store * fix api test * derp
Diffstat (limited to 'store/sqlstore/license_store_test.go')
-rw-r--r--store/sqlstore/license_store_test.go55
1 files changed, 55 insertions, 0 deletions
diff --git a/store/sqlstore/license_store_test.go b/store/sqlstore/license_store_test.go
new file mode 100644
index 000000000..053b0ede1
--- /dev/null
+++ b/store/sqlstore/license_store_test.go
@@ -0,0 +1,55 @@
+// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package sqlstore
+
+import (
+ "testing"
+
+ "github.com/mattermost/mattermost-server/model"
+"github.com/mattermost/mattermost-server/store"
+)
+
+func TestLicenseStoreSave(t *testing.T) {
+ ss := Setup()
+
+ l1 := model.LicenseRecord{}
+ l1.Id = model.NewId()
+ l1.Bytes = "junk"
+
+ if err := (<-ss.License().Save(&l1)).Err; err != nil {
+ t.Fatal("couldn't save license record", err)
+ }
+
+ if err := (<-ss.License().Save(&l1)).Err; err != nil {
+ t.Fatal("shouldn't fail on trying to save existing license record", err)
+ }
+
+ l1.Id = ""
+
+ if err := (<-ss.License().Save(&l1)).Err; err == nil {
+ t.Fatal("should fail on invalid license", err)
+ }
+}
+
+func TestLicenseStoreGet(t *testing.T) {
+ ss := Setup()
+
+ l1 := model.LicenseRecord{}
+ l1.Id = model.NewId()
+ l1.Bytes = "junk"
+
+ store.Must(ss.License().Save(&l1))
+
+ if r := <-ss.License().Get(l1.Id); r.Err != nil {
+ t.Fatal("couldn't get license", r.Err)
+ } else {
+ if r.Data.(*model.LicenseRecord).Bytes != l1.Bytes {
+ t.Fatal("license bytes didn't match")
+ }
+ }
+
+ if err := (<-ss.License().Get("missing")).Err; err == nil {
+ t.Fatal("should fail on get license", err)
+ }
+}