summaryrefslogtreecommitdiffstats
path: root/store/storetest/license_store.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-10-06 11:08:59 -0700
committerGitHub <noreply@github.com>2017-10-06 11:08:59 -0700
commit70e5f00241473c27a3008959ce08832c75e76ba8 (patch)
tree3afd074964c9220cc4a87210286a13dfd38c61d0 /store/storetest/license_store.go
parentd1958bdc49cd10277ca2e27bb2eea499c5994954 (diff)
downloadchat-70e5f00241473c27a3008959ce08832c75e76ba8.tar.gz
chat-70e5f00241473c27a3008959ce08832c75e76ba8.tar.bz2
chat-70e5f00241473c27a3008959ce08832c75e76ba8.zip
store/storetest package (#7588)
* prerequisites * storetest package
Diffstat (limited to 'store/storetest/license_store.go')
-rw-r--r--store/storetest/license_store.go56
1 files changed, 56 insertions, 0 deletions
diff --git a/store/storetest/license_store.go b/store/storetest/license_store.go
new file mode 100644
index 000000000..452d37e7b
--- /dev/null
+++ b/store/storetest/license_store.go
@@ -0,0 +1,56 @@
+// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package storetest
+
+import (
+ "testing"
+
+ "github.com/mattermost/mattermost-server/model"
+ "github.com/mattermost/mattermost-server/store"
+)
+
+func TestLicenseStore(t *testing.T, ss store.Store) {
+ t.Run("Save", func(t *testing.T) { testLicenseStoreSave(t, ss) })
+ t.Run("Get", func(t *testing.T) { testLicenseStoreGet(t, ss) })
+}
+
+func testLicenseStoreSave(t *testing.T, ss store.Store) {
+ 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 store.Store) {
+ 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)
+ }
+}