diff options
Diffstat (limited to 'store/sql_upgrade_test.go')
-rw-r--r-- | store/sql_upgrade_test.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/store/sql_upgrade_test.go b/store/sql_upgrade_test.go new file mode 100644 index 000000000..1ff68180d --- /dev/null +++ b/store/sql_upgrade_test.go @@ -0,0 +1,40 @@ +// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package store + +import ( + "testing" + + "github.com/mattermost/platform/model" +) + +func TestStoreUpgrade(t *testing.T) { + Setup() + + saveSchemaVersion(store.(*SqlStore), VERSION_3_0_0) + UpgradeDatabase(store.(*SqlStore)) + + store.(*SqlStore).SchemaVersion = "" + UpgradeDatabase(store.(*SqlStore)) +} + +func TestSaveSchemaVersion(t *testing.T) { + Setup() + + saveSchemaVersion(store.(*SqlStore), VERSION_3_0_0) + if result := <-store.System().Get(); result.Err != nil { + t.Fatal(result.Err) + } else { + props := result.Data.(model.StringMap) + if props["Version"] != VERSION_3_0_0 { + t.Fatal("version not updated") + } + } + + if store.(*SqlStore).SchemaVersion != VERSION_3_0_0 { + t.Fatal("version not updated") + } + + saveSchemaVersion(store.(*SqlStore), model.CurrentVersion) +} |