blob: 7c3b2f1246cbadfab62a6ba378139cd72ad2c5cd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
// Copyright (c) 2017-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 TestStoreUpgrade(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
saveSchemaVersion(ss.(*store.LayeredStore).DatabaseLayer.(SqlStore), VERSION_3_0_0)
UpgradeDatabase(ss.(*store.LayeredStore).DatabaseLayer.(SqlStore))
saveSchemaVersion(ss.(*store.LayeredStore).DatabaseLayer.(SqlStore), "")
UpgradeDatabase(ss.(*store.LayeredStore).DatabaseLayer.(SqlStore))
})
}
func TestSaveSchemaVersion(t *testing.T) {
StoreTest(t, func(t *testing.T, ss store.Store) {
saveSchemaVersion(ss.(*store.LayeredStore).DatabaseLayer.(SqlStore), VERSION_3_0_0)
if result := <-ss.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 ss.(*store.LayeredStore).DatabaseLayer.(SqlStore).GetCurrentSchemaVersion() != VERSION_3_0_0 {
t.Fatal("version not updated")
}
saveSchemaVersion(ss.(*store.LayeredStore).DatabaseLayer.(SqlStore), model.CurrentVersion)
})
}
|