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