Files
mattermost/store/sql_upgrade_test.go
Joram Wilander 6b61834ab1 Add store unit tests and add make target for testing store with postgres (#5925)
* Add store unit tests and add make target for testing store with postgres

* Remove postgres target form test-server target

* Fix audit test
2017-04-03 10:32:58 -07:00

41 lines
873 B
Go

// 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)
}