diff options
author | Chris <ccbrown112@gmail.com> | 2017-09-25 09:11:25 -0500 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2017-09-25 10:11:25 -0400 |
commit | 49fe5fbf3db56fc466b8997b182ee135d7a4365d (patch) | |
tree | 1252fea09aa3ce899e2e8edb1fb7b42900f50bca /store/sqlstore/license_store_test.go | |
parent | b2c5b97601b61f5748b46e4e386134203111ebb0 (diff) | |
download | chat-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.go | 55 |
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) + } +} |