mirror of
https://github.com/mattermost/focalboard.git
synced 2024-12-24 13:43:12 +02:00
03f4717e96
* WIP * Added migrations * Updating store method * WIP * WIP * Updated DND * WIP * WIP * WIP * WIP * WIP * wip * WIP * Adding new DB tool * Used migration functions in new migrations * Unique constraint migration * Unique constraint migration * Added SQLITE migrations * Added SQLITE support in few more migrations * Added SQLITE support in few more migrations * WIP * Used old-fashioned way to add unique constraint * Using oldsqlite method * Using oldsqlite method * Fixed all store and app layer tests * fixed integration tests * test and lint fix * Updated migration for MySQL and Postgres on personal server * Types fix * sqlite fix * fix typo * misc cleanup * added new tests * added new tests * de-duping input for postgres * integration tests, rmeoved uneeded migration * Added some migration tests * Added some migration tests * Fixed a test * completed migration tests * completed migration tests * Removed leftover debug statements Co-authored-by: Mattermost Build <build@mattermost.com>
135 lines
4.0 KiB
Go
135 lines
4.0 KiB
Go
package migrationstests
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func Test37MigrateHiddenBoardIDTest(t *testing.T) {
|
|
t.Run("no existing hidden boards exist", func(t *testing.T) {
|
|
th, tearDown := SetupTestHelper(t)
|
|
defer tearDown()
|
|
th.f.MigrateToStep(37)
|
|
})
|
|
|
|
t.Run("SQLite - existsing category boards with some hidden boards", func(t *testing.T) {
|
|
th, tearDown := SetupTestHelper(t)
|
|
defer tearDown()
|
|
|
|
if th.IsMySQL() || th.IsPostgres() {
|
|
return
|
|
}
|
|
|
|
th.f.MigrateToStep(36).
|
|
ExecFile("./fixtures/test37_valid_data_sqlite.sql")
|
|
|
|
th.f.MigrateToStep(37)
|
|
|
|
type categoryBoard struct {
|
|
User_ID string
|
|
Category_ID string
|
|
Board_ID string
|
|
Hidden bool
|
|
}
|
|
|
|
var hiddenCategoryBoards []categoryBoard
|
|
|
|
query := "SELECT user_id, category_id, board_id, hidden FROM focalboard_category_boards WHERE hidden = true"
|
|
err := th.f.DB().Select(&hiddenCategoryBoards, query)
|
|
require.NoError(t, err)
|
|
require.Equal(t, 3, len(hiddenCategoryBoards))
|
|
require.Contains(t, hiddenCategoryBoards, categoryBoard{User_ID: "user-id-1", Category_ID: "category-id-1", Board_ID: "board-id-1", Hidden: true})
|
|
require.Contains(t, hiddenCategoryBoards, categoryBoard{User_ID: "user-id-2", Category_ID: "category-id-3", Board_ID: "board-id-3", Hidden: true})
|
|
require.Contains(t, hiddenCategoryBoards, categoryBoard{User_ID: "user-id-2", Category_ID: "category-id-3", Board_ID: "board-id-4", Hidden: true})
|
|
})
|
|
|
|
t.Run("MySQL and PostgreSQL - existsing category boards with some hidden boards", func(t *testing.T) {
|
|
th, tearDown := SetupPluginTestHelper(t)
|
|
defer tearDown()
|
|
|
|
if th.IsSQLite() {
|
|
return
|
|
}
|
|
|
|
th.f.MigrateToStep(36).
|
|
ExecFile("./fixtures/test37_valid_data.sql")
|
|
|
|
th.f.MigrateToStep(37)
|
|
|
|
type categoryBoard struct {
|
|
User_ID string
|
|
Category_ID string
|
|
Board_ID string
|
|
Hidden bool
|
|
}
|
|
|
|
var hiddenCategoryBoards []categoryBoard
|
|
|
|
query := "SELECT user_id, category_id, board_id, hidden FROM focalboard_category_boards WHERE hidden = true"
|
|
err := th.f.DB().Select(&hiddenCategoryBoards, query)
|
|
require.NoError(t, err)
|
|
require.Equal(t, 3, len(hiddenCategoryBoards))
|
|
require.Contains(t, hiddenCategoryBoards, categoryBoard{User_ID: "user-id-1", Category_ID: "category-id-1", Board_ID: "board-id-1", Hidden: true})
|
|
require.Contains(t, hiddenCategoryBoards, categoryBoard{User_ID: "user-id-2", Category_ID: "category-id-3", Board_ID: "board-id-3", Hidden: true})
|
|
require.Contains(t, hiddenCategoryBoards, categoryBoard{User_ID: "user-id-2", Category_ID: "category-id-3", Board_ID: "board-id-4", Hidden: true})
|
|
})
|
|
|
|
t.Run("no hidden boards", func(t *testing.T) {
|
|
th, tearDown := SetupPluginTestHelper(t)
|
|
defer tearDown()
|
|
|
|
th.f.MigrateToStep(36).
|
|
ExecFile("./fixtures/test37_valid_data_no_hidden_boards.sql")
|
|
|
|
th.f.MigrateToStep(37)
|
|
|
|
var count int
|
|
query := "SELECT count(*) FROM focalboard_category_boards WHERE hidden = true"
|
|
err := th.f.DB().Get(&count, query)
|
|
require.NoError(t, err)
|
|
require.Equal(t, 0, count)
|
|
})
|
|
|
|
t.Run("SQLite - preference but no hidden board", func(t *testing.T) {
|
|
th, tearDown := SetupTestHelper(t)
|
|
defer tearDown()
|
|
|
|
if th.IsMySQL() || th.IsPostgres() {
|
|
return
|
|
}
|
|
|
|
th.f.MigrateToStep(36).
|
|
ExecFile("./fixtures/test37_valid_data_sqlite_preference_but_no_hidden_board.sql")
|
|
|
|
th.f.MigrateToStep(37)
|
|
|
|
var count int
|
|
query := "SELECT count(*) FROM focalboard_category_boards WHERE hidden = true"
|
|
err := th.f.DB().Get(&count, query)
|
|
require.NoError(t, err)
|
|
require.Equal(t, 0, count)
|
|
})
|
|
|
|
t.Run("MySQL and PostgreSQL - preference but no hidden board", func(t *testing.T) {
|
|
th, tearDown := SetupPluginTestHelper(t)
|
|
defer tearDown()
|
|
|
|
if th.IsSQLite() {
|
|
return
|
|
}
|
|
|
|
th.f.MigrateToStep(36).
|
|
ExecFile("./fixtures/test37_valid_data_preference_but_no_hidden_board.sql")
|
|
|
|
th.f.MigrateToStep(37)
|
|
|
|
var count int
|
|
query := "SELECT count(*) FROM focalboard_category_boards WHERE hidden = true"
|
|
err := th.f.DB().Get(&count, query)
|
|
require.NoError(t, err)
|
|
require.Equal(t, 0, count)
|
|
})
|
|
|
|
}
|