summaryrefslogtreecommitdiffstats
path: root/store/sql_store_test.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-09-25 09:11:25 -0500
committerJoram Wilander <jwawilander@gmail.com>2017-09-25 10:11:25 -0400
commit49fe5fbf3db56fc466b8997b182ee135d7a4365d (patch)
tree1252fea09aa3ce899e2e8edb1fb7b42900f50bca /store/sql_store_test.go
parentb2c5b97601b61f5748b46e4e386134203111ebb0 (diff)
downloadchat-49fe5fbf3db56fc466b8997b182ee135d7a4365d.tar.gz
chat-49fe5fbf3db56fc466b8997b182ee135d7a4365d.tar.bz2
chat-49fe5fbf3db56fc466b8997b182ee135d7a4365d.zip
Move sql store code into store/sqlstore package (#7502)
* move sql store code into store/sqlstore package * move non-sql constants back up to store * fix api test * derp
Diffstat (limited to 'store/sql_store_test.go')
-rw-r--r--store/sql_store_test.go147
1 files changed, 0 insertions, 147 deletions
diff --git a/store/sql_store_test.go b/store/sql_store_test.go
deleted file mode 100644
index 4be3352e9..000000000
--- a/store/sql_store_test.go
+++ /dev/null
@@ -1,147 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package store
-
-import "github.com/mattermost/mattermost-server/utils"
-
-var store Store
-
-func Setup() {
- if store == nil {
- utils.TranslationsPreInit()
- utils.LoadConfig("config.json")
- utils.InitTranslations(utils.Cfg.LocalizationSettings)
- store = NewLayeredStore(nil, nil)
-
- store.MarkSystemRanUnitTests()
- }
-}
-
-/*
-func TestSqlStore1(t *testing.T) {
- utils.TranslationsPreInit()
- utils.LoadConfig("config.json")
- utils.Cfg.SqlSettings.Trace = true
-
- store := NewSqlStore()
- store.Close()
-
- utils.Cfg.SqlSettings.DataSourceReplicas = []string{utils.Cfg.SqlSettings.DataSource}
-
- store = NewSqlStore()
- store.TotalMasterDbConnections()
- store.TotalReadDbConnections()
- store.Close()
-
- utils.LoadConfig("config.json")
-}
-
-func TestAlertDbCmds(t *testing.T) {
- Setup()
-
- sqlStore := store.(SqlStore)
-
- if !sqlStore.DoesTableExist("Systems") {
- t.Fatal("Failed table exists")
- }
-
- if sqlStore.DoesColumnExist("Systems", "Test") {
- t.Fatal("Column should not exist")
- }
-
- if !sqlStore.CreateColumnIfNotExists("Systems", "Test", "VARCHAR(50)", "VARCHAR(50)", "") {
- t.Fatal("Failed to create column")
- }
-
- maxLen := sqlStore.GetMaxLengthOfColumnIfExists("Systems", "Test")
-
- if maxLen != "50" {
- t.Fatal("Failed to get max length found " + maxLen)
- }
-
- if !sqlStore.AlterColumnTypeIfExists("Systems", "Test", "VARCHAR(25)", "VARCHAR(25)") {
- t.Fatal("failed to alter column size")
- }
-
- maxLen2 := sqlStore.GetMaxLengthOfColumnIfExists("Systems", "Test")
-
- if maxLen2 != "25" {
- t.Fatal("Failed to get max length")
- }
-
- if !sqlStore.RenameColumnIfExists("Systems", "Test", "Test1", "VARCHAR(25)") {
- t.Fatal("Failed to rename column")
- }
-
- if sqlStore.DoesColumnExist("Systems", "Test") {
- t.Fatal("Column should not exist")
- }
-
- if !sqlStore.DoesColumnExist("Systems", "Test1") {
- t.Fatal("Column should exist")
- }
-
- sqlStore.CreateIndexIfNotExists("idx_systems_test1", "Systems", "Test1")
- sqlStore.RemoveIndexIfExists("idx_systems_test1", "Systems")
-
- sqlStore.CreateFullTextIndexIfNotExists("idx_systems_test1", "Systems", "Test1")
- sqlStore.RemoveIndexIfExists("idx_systems_test1", "Systems")
-
- if !sqlStore.RemoveColumnIfExists("Systems", "Test1") {
- t.Fatal("Failed to remove columns")
- }
-
- if sqlStore.DoesColumnExist("Systems", "Test1") {
- t.Fatal("Column should not exist")
- }
-}
-
-func TestCreateIndexIfNotExists(t *testing.T) {
- Setup()
-
- sqlStore := store.(SqlStore)
-
- defer sqlStore.RemoveColumnIfExists("Systems", "Test")
- if !sqlStore.CreateColumnIfNotExists("Systems", "Test", "VARCHAR(50)", "VARCHAR(50)", "") {
- t.Fatal("Failed to create test column")
- }
-
- defer sqlStore.RemoveIndexIfExists("idx_systems_create_index_test", "Systems")
- if !sqlStore.CreateIndexIfNotExists("idx_systems_create_index_test", "Systems", "Test") {
- t.Fatal("Should've created test index")
- }
-
- if sqlStore.CreateIndexIfNotExists("idx_systems_create_index_test", "Systems", "Test") {
- t.Fatal("Shouldn't have created index that already exists")
- }
-}
-
-func TestRemoveIndexIfExists(t *testing.T) {
- Setup()
-
- sqlStore := store.(SqlStore)
-
- defer sqlStore.RemoveColumnIfExists("Systems", "Test")
- if !sqlStore.CreateColumnIfNotExists("Systems", "Test", "VARCHAR(50)", "VARCHAR(50)", "") {
- t.Fatal("Failed to create test column")
- }
-
- if sqlStore.RemoveIndexIfExists("idx_systems_remove_index_test", "Systems") {
- t.Fatal("Should've failed to remove index that doesn't exist")
- }
-
- defer sqlStore.RemoveIndexIfExists("idx_systems_remove_index_test", "Systems")
- if !sqlStore.CreateIndexIfNotExists("idx_systems_remove_index_test", "Systems", "Test") {
- t.Fatal("Should've created test index")
- }
-
- if !sqlStore.RemoveIndexIfExists("idx_systems_remove_index_test", "Systems") {
- t.Fatal("Should've removed index that exists")
- }
-
- if sqlStore.RemoveIndexIfExists("idx_systems_remove_index_test", "Systems") {
- t.Fatal("Should've failed to remove index that was already removed")
- }
-}
-*/