summaryrefslogtreecommitdiffstats
path: root/store/sql_upgrade_test.go
blob: 1ff68180dc9e433d5a3db5bcd3a8ce05ead792d5 (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
// 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)
}